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
>开发者_运维知识库; 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)
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?
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
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!
export NODE_PATH="/usr/local/lib/node_modules/"
rm -fr build
node-waf configure
node-waf build
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)
精彩评论