【问题标题】:Node-waf: not found节点 waf:未找到
【发布时间】:2013-04-25 10:34:45
【问题描述】:

事情就是这样。我的配置是 Ubuntu 13.04、Node.js v0.10.5 和 NPM 版本 1.2.18。

我正在尝试安装 node.js 模块“shoe”,但出现此错误:

marek@nassenfuss:/media/tc/examples/node/05.01$ sudo npm install
npm http GET https://registry.npmjs.org/shoe
npm http 304 https://registry.npmjs.org/shoe
npm http GET https://registry.npmjs.org/node-uuid/1.3.3
npm http GET https://registry.npmjs.org/faye-websocket/0.4.0
npm http GET https://registry.npmjs.org/rbytes/0.0.2
npm http 304 https://registry.npmjs.org/node-uuid/1.3.3
npm http 304 https://registry.npmjs.org/rbytes/0.0.2
npm http 304 https://registry.npmjs.org/faye-websocket/0.4.0

> rbytes@0.0.2 install /media/tc/examples/node/05.01/node_modules/shoe/node_modules/sockjs/node_modules/rbytes
> node-waf configure build

sh: 1: node-waf: not found
npm WARN optional dep failed, continuing rbytes@0.0.2
shoe@0.0.10 node_modules/shoe
├── sockjs-client@0.0.0-unreleasable
└── sockjs@0.3.1 (node-uuid@1.3.3, faye-websocket@0.4.0)
marek@nassenfuss:/media/tc/examples/node/05.01$

我在谷歌上搜索,发现 node-waf 被 node-gyp 替换了。我还发现node-waf可以安装

sudo apt-get install nodejs-dev

问题是我使用的是最新的node.js package by Chris Lea,它不再包括 dev。所以有两种方法可以解决这个问题。

首先,我可以安装 node-waf(从源代码?),但我不怎么安装。

其次,我可以(手动)修复模块,但我不会。

我正在寻找任何解决方案。

【问题讨论】:

标签: node.js npm


【解决方案1】:

node-waf 已替换为node-gyp

使用以下命令安装 node-gyp: sudo npm install -g node-gyp

注意:要使用 node-gyp 构建,需要配置文件 binding.gyp。 示例:

{
  "targets": [
    {
      "target_name": "binding",
      "sources": [ "src/binding.cc" ]
    }
  ]
}

【讨论】:

  • 更新我的package.json 以使用"engines": {"npm":"1.4.x"} 为我解决了这个问题。以前是1.3.x
【解决方案2】:

实际上是rbytes 导致了问题。

为了使其更加复杂:rbytes 不是 shoe 的直接依赖项,而是 sockjs 的直接依赖项。还有looking at the code,它也应该在没有rbytes 的情况下运行。

由于 shoe 声明是一个可选依赖,shoe 确实被安装了:

npm WARN optional dep failed, continuing rbytes@0.0.2
         ^^^^^^^^             ^^^^^^^^^^        

因此,无论警告如何,您都应该能够使用它。

【讨论】:

  • 感谢您的回答。尽管有警告,我不知道我可以使用“鞋子”。这基本上解决了我的问题。无论如何,我仍在寻找我的两个问题的答案。我在哪里可以获得 node-waf 或者如何在没有 NPM 的情况下安装模块。
  • node-waf 在 Node 0.8 中被弃用;它的替代品node-gyp 也无法构建rbytes(我尝试过:克隆存储库并使用node-gyp configure build)。如果你真的想使用它,你可以使用nvm 来安装 pre-0.8 Node。
【解决方案3】:

我没有运气在我的机器上安装 node-waf,所以我决定分叉并将它迁移到 node-gyp 以便它工作。

我的叉子在https://github.com/eddydas/node-sleep

要让它工作,首先确保你有 node-gyp by

$ npm install node-gyp

然后,从 GitHub 克隆整个项目(通过 ZIP 或 Git,由您决定)并从中安装。

$ cd ~
$ wget "https://codeload.github.com/eddydas/node-sleep/zip/master"
$ unzip master
$ cd YOUR_NODE_JS_PROJECT_FOLDER
$ npm install ~/node-sleep-master

我尽了最大的努力使事情顺利进行。如果它不顺利,请随时让我知道。希望对您有所帮助!

【讨论】:

    【解决方案4】:

    我只是升级了我的节点版本(从 0.4.4 升级到 0.6.2),问题就解决了。

    【讨论】:

      【解决方案5】:

      安装 node lts 版本为我解决了这个问题

      npm install n -g
      
      sudo n lts
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-02-13
        • 1970-01-01
        • 2018-11-27
        • 2018-04-21
        • 2020-09-09
        • 2017-07-15
        相关资源
        最近更新 更多