我正在打包一个节点应用程序以部署在没有 npm 的服务器上。我相信我已经弄清楚了 - 我使用 npm 根据 package.json 文件将所有依赖项安装在本地 node_modules 文件夹中。
一切似乎都运行良好,但是当我尝试从服务器运行节点文件时,它抱怨它Cannot find module '../build/Release/contextify'
.
这是有道理的,因为在 中node_modules/.npm/contextify/0.0.4/package/lib/contextify.js
,它要求有问题的文件,并且node_modules/.npm/contextify/0.0.4/package/build
没有名为Release
. 我假设 npm 只是没有构建版本,所以我切换回开发机器,然后运行npm install
- 它没有抱怨,它似乎构建了 contextify:
$ sudo npm install
> contextify@0.0.4 preinstall /path/to/node/stuff/node_modules/contextify
> node-waf clean || true; node-waf configure build
'clean' finished successfully (0.014s)
Setting srcdir to : /path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package
Setting blddir to : /path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package/build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local/Cellar/node/0.4.5
'configure' finished successfully (0.043s)
Waf: Entering directory `/path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package/build'
[1/2] cxx: src/contextify.cc -> build/default/src/contextify_1.o
[2/2] cxx_link: build/default/src/contextify_1.o -> build/default/contextify.node
Waf: Leaving directory `/path/to/node/stuff/node_modules/.npm/contextify/0.0.4/package/build'
'build' finished successfully (0.370s)
不幸的是,该package/build
目录仍然没有Release
文件夹。
所以,我想问题是 contextify 是否因为我的节点路径未设置而无法构建(我尝试过export NODE_PATH
,但它似乎没有帮助......),或者是否有其他原因 contextify 没有似乎正在建设。
也许我错过了更大的东西?