【问题标题】:npm doesn't build Contextify Release - node path not found?npm 不构建 Contextify Release - 找不到节点路径?
【发布时间】:2011-11-07 21:38:08
【问题描述】:

我正在打包一个节点应用程序以部署在没有 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 似乎没有构建的原因。

也许我错过了一些更大的东西?

【问题讨论】:

    标签: node.js packaging npm


    【解决方案1】:

    我也有同样的问题,

    您可能想将问题添加到 github,作者可能会比这里更快地帮助您。 https://github.com/brianmcd/contextify/issues?sort=created&direction=desc&state=closed&page=1

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

        我认为你的 nodejs 的本地版本是 v.0.4.*,而你的 nodejs 的服务器版本是 v0.5.*

        确保在开发和生产中使用相同版本的 nodejs。如果您切换到 v0.4.*,我敢打赌您的问题将得到解决。我注意到在 5.* 版本中,node-waf 的“构建”配置从“默认”切换到“发布”。

        但是有一个警告:

        一些 npm 包正在使用(编译的)二进制文件。 I.M.O,您不应该将“已编译”的 node_modules 捆绑在一个包中以将其部署在没有 npm 的“不同”平台上。遇到问题只是时间问题。 (和上面一样)

        【讨论】:

        猜你喜欢
        • 2020-10-03
        • 1970-01-01
        • 2019-05-04
        • 1970-01-01
        • 1970-01-01
        • 2016-07-27
        • 2010-12-08
        • 2012-12-01
        • 1970-01-01
        相关资源
        最近更新 更多