【发布时间】:2016-06-07 04:13:37
【问题描述】:
我有一个简化的结构看起来像这样的网络应用程序。
.
├── app.js
├── native_modules
│ └── my_module_addon
│ ├── binding.gyp
│ ├── index.js
│ ├── node_modules
│ ├── package.json
│ ├── my_module_addon.cc
├── node_modules
├── package.json
我已经开发了原生模块插件并链接了它。 从 repo 获取项目后,我想轻松安装我的原生插件,只需调用 npm,然后自动调用 node-gyp rebuild。
npm install
好吧,我的应用 package.json:
{
"name": "MyWebApp",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"express": "~4.13.1",
"my_module_addon": "file:./native_modules/my_module_addon"
}
}
还有我的模块 package.json:
{
"name": "scs3reader_addon",
"version": "1.0.0",
"description": "My Awesome Addon",
"main": "index.js",
"scripts": {
"install": "node-gyp rebuild"
},
"license": "MIT",
"dependencies": {
"bindings": "^1.2.1",
"nan": "^2.2.0"
},
"gypfile": true
}
为了链接我的原生插件,我将它添加到依赖项中
"my_module_addon": "file:./native_modules/my_module_addon"
当我在网络应用程序上调用 npm install 时出现问题我已经安装了所有模块并执行了 node-gyp,但不知道为什么本地插件没有构建文件夹和输出文件。
> node-gyp rebuild
CXX(target) Release/obj.target/my_module_addon/my_module_addon.o
SOLINK_MODULE(target) Release/my_module_addon.node
my_module_addon@1.0.0 node_modules/my_module_addon
├── bindings@1.2.1
└── nan@2.2.0
【问题讨论】:
标签: node.js module installation npm node-gyp