使用nw.gyp为nw.js构建serialport.js [英] building serialport.js with nw.gyp for nw.js
问题描述
我正在尝试将 serialport.js 与我的 nw.js应用打包在一起.我很难为 nw.js 构建 serialport.js .
I'm trying to package serialport.js with my nw.js app. I'm having a hard time building serialport.js for nw.js.
我已经使用npm在"app \ resource \ node_modules" 中安装了 serialport.js .
I've installed serialport.js in my "app\resource\node_modules" using npm.
我还全局安装了 nw.gyp "npm install nw-gyp -g"
然后我将目录更改为 binding.gyp 所在的"app \ resource \ node_modules \ serialport" ,并尝试使用nw-gyp 重建串行端口"nw-gyp rebuild --target = 0.12.3"
Then I changed directory to "app\resource\node_modules\serialport" where the binding.gyp is located and tried to rebuild serialport with nw-gyp "nw-gyp rebuild --target=0.12.3"
这是我得到的错误: binding.gyp中的未定义变量module_name
This is the error I got: Undefined variable module_name in binding.gyp
有什么想法可以解决这个问题吗?
Any Ideas how I can get passed this problem?
其他人似乎也有类似的问题: Node-webkit(nw.js)中的Serialport.js在Win 7上
Other's seem to have similar problems: Serialport.js in Node-webkit (nw.js) on Win 7
我还看到不同的节点模块发生了相同的错误: 使用nw-gyp构建node-sqlite3
I also saw the same error happening with a different node module: Building node-sqlite3 with nw-gyp
推荐答案
打开 node_modules/serialport/binding.gyp ,您需要进行一些更改...
open node_modules/serialport/binding.gyp, you need make some changes...
之前:
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "<(module_name)" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/<(module_name).node" ],
"destination": "<(module_path)"
之后:
"target_name": "action_after_build",
"type": "none",
"dependencies": [ "serialport" ],
"copies": [
{
"files": [ "<(PRODUCT_DIR)/serialport.node" ],
"destination": "."
并在 node_modules/serialport/package.json 中将 module_path 更改为:
"module_path": "./build/{configuration}/",
最后,运行 nw-gyp rebuild --target = 0.12.3
这篇关于使用nw.gyp为nw.js构建serialport.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!