节点WebKit和SerialPort

我正在使用Node WebKit开发一个应用程序,我需要访问我的PC的串行端口(Windows 8)。

对于使用C / C ++插件安装第三方模块,我按照以下链接中的指南: https : //github.com/nwjs/nw.js/wiki/Using-Node-modules#3rd-party-modules-with-cc – 漫画 。 当我用命令“nw-gyp rebuild –target = 0.12.4”重build模块“serialport”(以前用“npm install serialport”命令安装),我得到以下错误:

gyp: Undefined variable module_name in binding.gyp gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (C:\Users\LucaG.SEAV\AppData\Roaming \npm\node_modules\nw-gyp\lib\configure.js:353:16) gyp ERR! stack at ChildProcess.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820: 12) gyp ERR! System Windows_NT 6.2.9200 gyp ERR! command "node" "C:\\Users\\LucaG.SEAV\\AppData\\Roaming\\npm\\node_modu les\\nw-gyp\\bin\\nw-gyp.js" "rebuild" "--target=0.12.2" gyp ERR! cwd C:\Sources\INT2292App\node_modules\serialport gyp ERR! node -v v0.10.40 gyp ERR! nw-gyp -v v0.12.4 gyp ERR! not ok 

我看到第一个错误是“gyp:binding.gyp中未定义variablesmodule_name”

我怎么解决这个问题?

我正在使用Node WebKit的v0.12.3

我努力了解如何解决这个问题。 我已经将其构build在Windows 7 SP1上,但在Windows 8上,程序不能这么不同。

  • serialport 文档精确地说,你必须安装Python 2.x而不是3.x. 所以你可以在主要的python网站http://python.org上find它
  • 如果您不想安装Visual Studio,请安装Microsoft Visual C ++ Build Tools 2015。 您需要login才能这样做。 你也可以使用Visual Studio社区版本并安装VC ++。

  • 确保您的环境variables%INCLUDE%指向正确的文件夹。 它必须包含stdio.h 。 我的是c:\ Program Files(x86)\ Windows Kits \ 10 \ Include \ 10.0.10150.0 \ ucrt。 您可以通过以下方式在cmd.exe中查看它:
    echo %INCLUDE%
    如果不是,可以通过以下方式设置:
    set INCLUDE=%INCLUDE%;YOUR_PATH

  • 全局安装所需的构build包:

    npm install -g node-gyp node-pre-gyp nw-gyp

  • 转到您的serialport文件夹并启动构build:
    cd project\node_modules\serialport node-pre-gyp rebuild --runtime=node-webkit --target=0.18.3 --target_arch=x64 --target-platform=win32

是的,这个模块在nwjs中有一些问题。 尝试我的构build: https ://mega.nz/#!8Rl1BADa!icijUMsn5ndD-TM22K3gwCGGdoN2PUomA3mUjq6pmDY我用nwjs早期实际项目中使用它,但我没有用12.3testing它,我不知道它是否会工作。