npm 未构建 Contextify Release - 未找到节点路径?
我正在努力打包一个节点应用程序,以便在没有 npm 的情况下部署在服务器上。我相信我已经弄清楚了 - 我使用 npm 根据 package.json 文件在本地 node_modules 文件夹中安装所有依赖项。
这一切似乎运行良好,但是当我尝试从服务器运行节点文件时,它抱怨它找不到模块'../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
> [email protected] 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)
不幸的是,< code>package/build 目录仍然没有 Release
文件夹。
所以,我想问题是 contextify 是否无法构建,因为我的节点路径未设置(我尝试了 export NODE_PATH
,但它似乎没有帮助......),或者如果有contextify 似乎没有构建的其他一些原因。
也许我错过了更大的东西?
I'm working on packaging a node app to be deployed on a server without npm. I believe I have it figured out - I used npm to install all the dependencies in a local node_modules folder according to a package.json file.
It all appears to work well, but when I attempt to run the node file from the server, it complains that it Cannot find module '../build/Release/contextify'
.
That makes sense, because in node_modules/.npm/contextify/0.0.4/package/lib/contextify.js
, it asks for the file in question, and node_modules/.npm/contextify/0.0.4/package/build
has no directory called Release
. I assumed that npm just hadn't built the release, so I switched back to the dev machine, and ran npm install
- it didn't complain, and it appeared to build contextify:
$ sudo npm install
> [email protected] 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)
unfortunately, the package/build
directory still doesn't have a Release
folder.
So, I guess the question is if contextify is failing to build because my node path isn't set (I tried export NODE_PATH
, but it didn't seem to help...), or if there is some other reason that contextify doesn't appear to be building.
Maybe I'm missing something larger?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也遇到了同样的问题,
你可能想将问题添加到github,作者也许能够比在这里更快地帮助你。
https://github.com/brianmcd /contextify/issues?sort=created&direction=desc&state=close&page=1
I too am having the same issue,
You may want to add the issue to github, the author may be able to help you sooner than on here.
https://github.com/brianmcd/contextify/issues?sort=created&direction=desc&state=closed&page=1
解决这个错误的方法就是删除waf的“build”目录,然后重新配置。由于缺少 NODE_PATH,waf 会以某种方式缓存错误的配置结果,因此即使您记住并设置它,尽管配置报告没有错误,但它实际上不会编译任何内容。愚蠢的!
The fix for this error is just to remove waf's "build" directory, then re-configure. Somehow waf caches the bad config result due to a missing NODE_PATH, so even if you then remember and set it, it won't actually compile anything despite the configure reporting no errors. Silly!
我认为您的本地版本的nodejs是v.0.4.*,您的服务器版本的nodejs是v0.5.*
确保您使用相同版本的nodejs进行开发和生产。如果您切换到 v0.4.* 我敢打赌您的问题将会得到解决。我注意到在 5.* 版本中,node-waf 的“构建”配置从“默认”切换为“发布”。
但有一个警告:
某些 npm 包正在使用(编译的)二进制文件。 IMO,您不应该将“已编译”的 node_modules 捆绑在一个包中,以便将其部署在没有 npm 的“不同”平台上。遇到问题只是时间问题。 (就像上面那个一样)
I think your local version of nodejs is v.0.4.* and your server version of nodejs is v0.5.*
Make sure you use the same version of nodejs for dev and production. If you switch to v0.4.* I bet your problem will be solved. I noticed that the node-waf 'build' configuration is switched from 'default' to 'Release' somewhere in the 5.* versions.
One warning however:
Some npm packages are using (compiled) binaries. I.M.O, you should not bundle 'compiled' node_modules in one package to deploy it on a 'different' platform without npm. It's a matter of time before you will running into problems. (like the one above)