npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nwjc-compiler-service

v1.1.0

Published

Distributed nwjc compilation service for NW.js multi-platform builds

Readme

nwjc-compiler-service

分布式 nwjc 编译服务,用于 NW.js 多平台打包。

安装

# 全局安装(推荐)
npm install -g nwjc-compiler-service

# 或使用 npx(无需安装)
npx nwjc-compiler-service

使用

🚀 快速开始(交互式配置)

第一次运行:

npx nwjc-compiler-service

服务会自动询问 nwjc 路径:

❓ 未找到 nwjc 工具,需要配置 nwjc 路径

请输入 nwjc.exe 的完整路径:
  Windows 示例: C:\Users\YourName\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe
  macOS 示例: /path/to/nwjs-sdk/nwjc
  Linux 示例: /path/to/nwjs-sdk/nwjc

💡 提示: 按 Enter 跳过,稍后通过环境变量 NWJC_PATH 指定

nwjc 路径: C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe
✅ 配置已保存到: C:\Users\jiayq\.nwjc-compiler-service.json

以后每次运行:

npx nwjc-compiler-service
# 自动使用保存的配置,无需再次输入!

⚙️ 高级用法

使用 CLI 参数(跳过交互式询问):

# 指定 nwjc 路径
npx nwjc-compiler-service --nwjc-path "C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe"

# 指定端口
npx nwjc-compiler-service --port 4000

# 组合参数
npx nwjc-compiler-service --nwjc-path "C:\path\to\nwjc.exe" --port 4000

使用环境变量:

# Windows (CMD)
set NWJC_PATH=C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe
npx nwjc-compiler-service

# Windows (PowerShell)
$env:NWJC_PATH="C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe"
npx nwjc-compiler-service

# macOS/Linux
export NWJC_PATH=/path/to/nwjc
npx nwjc-compiler-service

📋 配置文件

配置保存在 ~/.nwjc-compiler-service.json

{
  "nwjcPath": "C:\\Users\\jiayq\\Desktop\\nwjs-sdk-v0.109.0-win-x64\\nwjc.exe",
  "port": 3001,
  "host": "0.0.0.0"
}

修改已保存的配置:

# 方式一:使用 CLI 参数覆盖
npx nwjc-compiler-service --nwjc-path "C:\new\path\to\nwjc.exe"

# 方式二:直接编辑配置文件
# Windows: notepad C:\Users\jiayq\.nwjc-compiler-service.json
# macOS/Linux: vi ~/.nwjc-compiler-service.json

配置优先级(从高到低):

  1. CLI 参数(如 --nwjc-path
  2. 环境变量(如 NWJC_PATH
  3. 配置文件(~/.nwjc-compiler-service.json
  4. 交互式输入
  5. 默认值

CLI 参数

| 参数 | 说明 | 示例 | |------|------|------| | --nwjc-path / -n | 指定 nwjc 工具路径 | --nwjc-path "C:\path\to\nwjc.exe" | | --port / -p | 指定端口号(默认:3001) | --port 4000 | | --host | 指定监听地址(默认:0.0.0.0) | --host 127.0.0.1 | | --help | 显示帮助信息 | --help |

API

1. 编译 JavaScript

curl -X POST http://localhost:3001/compile \
  -H "Content-Type: application/json" \
  -d '{
    "sourceCode": "function test() { return 42; }",
    "filename": "test.js"
  }'

响应:

{
  "success": true,
  "platform": {
    "platform": "darwin",
    "arch": "arm64",
    "platformArch": "osx-arm64"
  },
  "binFilename": "test.bin",
  "binData": "base64编码的二进制数据",
  "sourceSize": 1234,
  "binSize": 567,
  "compileTime": 123,
  "requestId": "xxx"
}

2. 健康检查

curl http://localhost:3001/health

响应:

{
  "status": "ok",
  "platform": {
    "platformArch": "win-x64"
  },
  "nwjcPath": "C:\\Users\\jiayq\\Desktop\\nwjs-sdk-v0.109.0-win-x64\\nwjc.exe",
  "timestamp": "2026-03-09T12:00:00.000Z"
}

3. 获取平台信息

curl http://localhost:3001/platform

环境要求

  • Node.js 16+
  • NW.js SDK(nwjc 工具)

配置

指定 nwjc 路径

方式一:CLI 参数(推荐)

npx nwjc-compiler-service --nwjc-path "C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe"

方式二:环境变量

# Windows (CMD)
set NWJC_PATH=C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe
npx nwjc-compiler-service

# Windows (PowerShell)
$env:NWJC_PATH="C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe"
npx nwjc-compiler-service

# macOS/Linux
export NWJC_PATH=/path/to/nwjc
npx nwjc-compiler-service

方式三:自动查找 服务会按以下顺序查找 nwjc:

  1. 环境变量 NWJC_PATH(优先级最高)
  2. 当前项目 node_modules/.bin/nwjc
  3. 当前项目 node_modules/nw/bin/nwjc
  4. 当前项目 sdk/nwjs-sdk-*/nwjc
  5. 全局 npm 安装路径

防火墙

确保端口可被外部访问:

  • macOS: 系统偏好设置 → 安全性与隐私 → 防火墙
  • Linux: sudo ufw allow 3001
  • Windows: Windows Defender 防火墙

日志输出

服务提供详细的日志输出,包括:

[2026-03-09T12:00:00.000Z] GET /health from ::1
[2026-03-09T12:00:01.000Z] POST /compile from 192.168.1.100
[abc123] 📝 收到编译请求: test.js
[abc123]    源代码长度: 1234 字节
[abc123]    客户端: 192.168.1.100
[abc123] 🔧 开始编译...
[abc123] 📁 临时目录: /tmp/nwjc-compile-xxx
[abc123] 📄 源文件: /tmp/nwjc-compile-xxx/test.js
[abc123] ✅ 源代码已写入 (1234 字节)
[abc123] 🔍 查找 nwjc 工具...
[abc123] 🔍 搜索路径 (5 个):
[abc123]    [1] C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe (环境变量)
[abc123]    ✅ 找到!
[abc123] ✅ 找到 nwjc: C:\Users\jiayq\Desktop\nwjs-sdk-v0.109.0-win-x64\nwjc.exe
[abc123] 🔨 执行编译: nwjc "source.js" "source.bin"
[abc123] ✅ nwjc 执行成功 (1234ms)
[abc123] ✅ 编译产物: source.bin (567 bytes)
[abc123] 🧹 临时文件已清理
[abc123] ✅ 编译成功!
[abc123]    输出文件: test.bin
[abc123]    源文件: 1234 bytes
[abc123]    编译后: 567 bytes
[abc123]    耗时: 1234ms
[abc123]    总耗时: 1250ms

开发

# 克隆仓库
git clone https://github.com/land007/nwjc-compiler-service.git
cd nwjc-compiler-service

# 安装依赖
npm install

# 开发模式(自动重启)
npm run dev

# 生产模式
npm start

# 全局链接(用于测试)
npm link
nwjc-service

许可证

MIT