【问题标题】:Node WebKit and SerialPort节点 WebKit 和 SerialPort
【发布时间】:2016-02-10 08:58:47
【问题描述】:

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

为了安装带有 C/C++ 插件的 3rd 方模块,我按照以下链接中的指南进行操作: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

【问题讨论】:

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


    【解决方案1】:

    是的,这个模块在 nwjs 中有一些问题。试试我的构建:https://mega.nz/#!8Rl1BADa!icijUMsn5ndD-TM22K3gwCGGdoN2PUomA3mUjq6pmDY 我很早就用nwjs在实际项目中使用过,但是我没有用12.3测试过,不知道能不能用。

    【讨论】:

    • 非常感谢 VoidVolker。我尝试使用在互联网上找到的另一个构建,并且似乎它运行良好(使用旧版本的节点 webkit)但是,我也想尝试你的构建。可以给我下载的密码吗?
    • 谢谢。我会尽快尝试。
    【解决方案2】:

    我努力了解如何解决这个问题。我已经在 Windows 7 sp1 上构建了它,但在 Windows 8 上的过程不能如此不同。

    • serialport 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 文件 (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

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

    【讨论】:

      猜你喜欢
      • 2013-01-25
      • 1970-01-01
      • 1970-01-01
      • 2014-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-10
      相关资源
      最近更新 更多