javascript - Node WebKit 和 SerialPort

标签 javascript node.js serial-port webkit node-webkit

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

为了使用 C/C++ 插件安装第 3 方模块,我遵循了以下链接中的指南:https://github.com/nwjs/nw.js/wiki/Using-Node-modules#3rd-party-modules-with-cc-addons .当我使用命令“nw-gyp rebuild --target=0.12.4”重建模块“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: undefined variable module_name in binding.gyp”

我该如何解决这个问题?

我使用的是 Node WebKit v0.12.3

最佳答案

我努力了解如何解决这个问题。我在 Windows 7 sp1 上构建它,但在 Windows 8 上的过程一定不会有太大不同。

  • 串口 doc准确地说,您必须安装 python 2.x 而不是 3.x。 所以你可以在主要的 python 网站上找到它 http://python.org
  • 如果您不想安装 visual studio,请安装 Microsoft Visual C++ Build Tools 2015。您需要登录才能这样做。您也可以使用 visual studio 社区版并安装 VC++。

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

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

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

  • 转到您的串行端口文件夹并启动构建:
    cd 项目\node_modules\serialport node-pre-gyp 重建 --runtime=node-webkit --target=0.18.3 --target_arch=x64 --target-platform=win32

关于javascript - Node WebKit 和 SerialPort,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33613788/

相关文章:

c++ - 无法向 com 端口发送数据

api - 投影仪控制 - RS232/USB?

c++ - 错误消息 : Serial communication between c++ GUI and Arduino

javascript - 循环 json 时更改 key

javascript - BreezeJS "group by"方法

javascript - 如何将 iPhone 重定向到 iTunes?

node.js - Electron 运行多个主进程与多个浏览器窗口

javascript - 如何将纯字符串附加到 div 中?

javascript - 在异步环境中保持 Node 函数参数的安全

node.js - 如何获得可用的 Mongoose 鉴别器列表?