NodeJS - 使用NPM安装时出错

Sha*_*uri 194 node.js 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>
Run Code Online (Sandbox Code Playgroud)

我正在安装某个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>
Run Code Online (Sandbox Code Playgroud)

Ila*_*mer 361

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

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

2016年2月2日更新

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

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

在此输入图像描述

2016年9月更新

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

 $ npm install --global --production windows-build-tools
Run Code Online (Sandbox Code Playgroud)

然后安装包

 $ npm install --global node-gyp
Run Code Online (Sandbox Code Playgroud)

更新06/2018

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

删除$ HOME/.node-gyp目录,然后重试.

请参阅此处的完整文档:node-gyp

  • 这不是通过在Windows上安装不依赖于VS的C++编译器来解决的吗?是不是找不到这样的事情?我糊涂了. (4认同)

Ton*_*gan 16

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

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

例子:

  • GYP_MSVS_VERSION=2012为Visual Studio 2012 设置
  • 设置GYP_MSVS_VERSION=2013e('e'代表免费'快递版')

有关完整列表,请参阅 - https://github.com/joyent/node/blob/v0.10.29/tools/gyp/pylib/gyp/MSVSVersion.py#L209-294

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

随意添加您的投票:

  • 我(最后)让它与VS 2015社区版合作.我在Window 10,64位.我在命令提示符中使用了"npm config set msvs_version 2015 -g"(当然是在安装VS之后).随着时间的推移,大多数人都会出现这个问题,建议使用VS2010,有时甚至是2013年,但我至少解决了VS2015目前的节点问题.我不得不"npm install -g sigmund"并从Github手动安装"lru-cache".最初的问题是安装了"Utf-8-Validate",作为Aurelia样本的依赖. (4认同)

小智 10

我遇到了错误的问题:

gyp ERR! configure error

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
Run Code Online (Sandbox Code Playgroud)

这是我正在做的事情和最终奏效的事情.

免责声明:我在Java,Linux世界等多年后,刚刚接手Node,Angular ......

环境描述:Windows 8.1 64位; Cygwin的; cygwin bash shell

使用的命令导致错误:npm install -g karma

错误:gyp ERR!配置错误gyp ERR!stack错误:找不到Python可执行文件"python",可以设置PYT HON env变量.

发现:bash shell上的'python'清楚地显示'/ usr/bin/python'.现在这很烦人!

解决方案:这仅适用于那些使用类似于我所拥有的环境的人,即使用cygwin和bash shell.希望它在其他环境中也有帮助,但请记住,你的茶壶可能看起来与我的有点不同.

  1. 首先,需要使用python可执行文件的显式窗口路径在.bashrc中设置$ PYTHON shell env变量,而不是像cygwin使用的根路径(/ usr/bin)这样的unix.
  2. 其次,这个尝试了大量的试验/错误,这就是问题!Cygwin在/ usr/bin下安装python(它实际上是windows上/ bin的镜像)与版本,即(在我的系统中)/usr/bin/python2.7.exe,然后添加一个链接/ usr/bin/python - > python2.7.exe.问题是gyp不能遵循这个链接,并继续给出令人烦恼的错误,即它无法找到python,即使你可以从shell命令行找到它.
  3. 在上面的背景下,现在将以下行添加到.bashrc中

export PYTHON ="C:/cygwin64/bin/python2.7.exe(或者系统上的任何版本)"

  1. 现在从您的主目录(在cygwin上)中获取.bashrc - >'source .bashrc'

你现在应该没问题,gyp会找到python可执行文件.

我希望这有助于某人在相同或类似问题上遇到麻烦.