Node WebKit和SerialPort

3
我正在使用Node WebKit开发应用程序,需要访问我的PC(Windows 8)的串行端口。为了安装带有C/C++插件的第三方模块,我按照以下链接的指南进行操作:https://github.com/nwjs/nw.js/wiki/Using-Node-modules#3rd-party-modules-with-cc-addons。当我使用命令“nw-gyp rebuild --target=0.12.4”重新构建先前使用“npm install serialport”命令安装的“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中未定义变量module_name”

我该如何解决这个问题?

我正在使用Node WebKit的v0.12.3版本

2个回答

2

我努力学习了如何解决这个问题。我在Windows 7 sp1上构建它,但是在Windows 8上步骤可能不会有太大区别。

  • serialport 文档 明确指出您必须安装Python 2.x而不是3.x。因此,您可以在主要的Python网站http://python.org上找到它。
  • 如果您不想安装Visual Studio,则需要安装Microsoft Visual C++ Build Tools 2015。您需要登录才能这样做。您也可以使用Visual Studio Community Edition并安装VC++。

  • 确保您的环境变量%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

  • 全局安装所需的构建软件包:

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

  • 进入serialport文件夹并启动构建:
    cd project\node_modules\serialport node-pre-gyp rebuild --runtime=node-webkit --target=0.18.3 --target_arch=x64 --target-platform=win32

0

非常感谢VoidVolker。 我尝试使用在互联网上找到的另一个构建,似乎它可以很好地工作(使用旧版本的node webkit),但是我也想尝试您的构建。您能给我下载密码吗? - LucaGSeav
谢谢。我会尽快尝试它。 - LucaGSeav

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接