npm 未构建 Contextify Release - 未找到节点路径?

发布于 2024-12-02 08:58:27 字数 2091 浏览 2 评论 0原文

我正在努力打包一个节点应用程序,以便在没有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ゞ记忆︶ㄣ 2024-12-09 08:58:27

我也遇到了同样的问题,

你可能想将问题添加到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

迟到的我 2024-12-09 08:58:27

解决这个错误的方法就是删除waf的“build”目录,然后重新配置。由于缺少 NODE_PATH,waf 会以某种方式缓存错误的配置结果,因此即使您记住并设置它,尽管配置报告没有错误,但它实际上不会编译任何内容。愚蠢的!

export NODE_PATH="/usr/local/lib/node_modules/"
rm -fr build
node-waf configure
node-waf build

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
没企图 2024-12-09 08:58:27

我认为您的本地版本的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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文