NodeJS - 使用 NPM 安装时出错

新手上路,请多包涵
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>npm install caress-server
npm http GET https://registry.npmjs.org/caress-server
npm http 304 https://registry.npmjs.org/caress-server
npm http GET https://registry.npmjs.org/jspack/0.0.1
npm http GET https://registry.npmjs.org/buffertools
npm http 304 https://registry.npmjs.org/jspack/0.0.1
npm http 304 https://registry.npmjs.org/buffertools

> buffertools@2.0.1 install C:\Windows\system32\node_modules\caress-server\node_
modules\buffertools
> node-gyp rebuild

C:\Windows\system32\node_modules\caress-server\node_modules\buffertools>node "G:
\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-
gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at failNoPython (G:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:101:14)
gyp ERR! stack     at G:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:64:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "G:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\
bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Windows\system32\node_modules\caress-server\node_modules\buffert
ools
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! buffertools@2.0.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the buffertools@2.0.1 install script.
npm ERR! This is most likely a problem with the buffertools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls buffertools
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\\nodejs\\\\node.exe" "G:\\nodejs\\node_modules\\npm\\bin\\n
pm-cli.js" "install" "caress-server"
npm ERR! cwd C:\Windows\system32
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Windows\system32\npm-debug.log
npm ERR! not ok code 0

C:\Windows\system32>

我正在安装某个 NodeJS 脚本 - Caress 。但我不是不能。我使用的是 Windows 8.1,谁能告诉我我面临的问题是什么,为什么这个安装不起作用。据我所知,buffertools 依赖项似乎存在问题。不知道如何解决这个问题?

如果我从 github 下载构建并将其放在节点模块中,似乎没有任何效果。当我尝试启动时,使用 npm start 或在实施期间。

 G:\nodejs\node_modules\caress-server>npm install

G:\nodejs\node_modules\caress-server>npm start

> caress-server@0.1.1 start G:\nodejs\node_modules\caress-server
> node examples/server.js

   info  - socket.io started

module.js:340
    throw err;
          ^
Error: Cannot find module './build/Release/buffertools.node'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (G:\nodejs\node_modules\caress-server\node_modules\buf
fertools\buffertools.js:16:19)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

npm ERR! caress-server@0.1.1 start: `node examples/server.js`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the caress-server@0.1.1 start script.
npm ERR! This is most likely a problem with the caress-server package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node examples/server.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls caress-server
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "G:\\nodejs\\\\node.exe" "G:\\nodejs\\node_modules\\npm\\bin\\n
pm-cli.js" "start"
npm ERR! cwd G:\nodejs\node_modules\caress-server
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     G:\nodejs\node_modules\caress-server\npm-debug.log
npm ERR! not ok code 0

G:\nodejs\node_modules\caress-server>

原文由 Shaurya Chaudhuri 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 913
2 个回答

如下所述,您可能不需要在 Windows 上安装 VS,请查看

https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245

2016 年 2 月更新

一些npm插件需要安装 node-gyp

但是, node-gyp 有它自己的依赖项( 来自 github 页面):

在此处输入图像描述

2016 年 9 月更新

如果您使用的是 Windows,您现在可以使用单个命令安装所有 node-gyp 依赖项(注意:在 Windows PowerShell 中以管理员身份运行):

  $ npm install --global --production windows-build-tools

然后安装包

 $ npm install --global node-gyp

2018 年 6 月更新

https://github.com/nodejs/node-gyp/issues/809#issuecomment-155019383

删除您的 $HOME/.node-gyp 目录并重试。

在此处查看完整文档: node-gyp

原文由 Ilan Frumer 发布,翻译遵循 CC BY-SA 4.0 许可协议

注意:这是适用于早期版本的 NodeJS 的旧答案。衷心感谢这些开源项目响应了这个问题,解决了这个曾经的痛苦。

确保您拥有运行所需的所有软件 node-gyp

您可以通过环境变量配置 node-gyp 使用的 Visual Studio 版本,这样您就可以避免每次执行 npm 安装时都必须设置 --msvs_version=2012 属性。

例子:

  • 为 Visual Studio 2012 设置 GYP_MSVS_VERSION=2012
  • 设置 GYP_MSVS_VERSION=2013e (’e’ 代表免费的’快速版’)

完整列表见

这对于 NodeJS 的 Windows 用户来说仍然是痛苦的,因为它假定您安装了 Visual Studio 的副本,而许多最终用户永远不会拥有它。所以我正在游说 Joyent,鼓励他们将 Web 套接字作为 CORE 节点的一部分,并且可能将 GNU gcc 编译器作为 NodeJS 安装的一部分,这样我们就可以永久解决这个问题。

欢迎在以下位置添加您的投票:

原文由 Tony O‘Hagan 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题