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 脚本 -爱抚。但我不能。我正在使用 Windows 8.1,谁能告诉我我面临的问题是什么,为什么这个安装不工作。在我看来,Buffertools 依赖性似乎有一个问题。不知道怎么解决这个问题?

如果我从 github 下载构建并将其放在 node-module 中,似乎什么都不能工作。当我尝试启动时,使用 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>
324282 次浏览
正如下面所评论的,你可能不需要在窗口上安装VS,看看这个

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

更新02/2016

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

然而,node-gyp有自己的依赖项(来自github页面):

enter image description here

更新09/2016

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

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

然后安装包

 $ npm install --global node-gyp

更新06/2018

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

删除$HOME/。Node-gyp目录后重试。

查看完整文档:node-gyp

注意:这是一个适用于早期版本的NodeJS的旧答案。我真诚地感谢这些开源项目,它们回应了这个问题,解决了以前的痛苦。

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

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

例子:

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

完整的列表见

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

欢迎在以下地址投票:

我遇到了错误的问题:

gyp ERR! configure error


gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

这是我一直在做的事情,最后成功了。

免责声明:在Java、Linux等世界工作多年后,我刚刚接触到Node、Angular……

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

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

< p > 错误: 骗子犯错!配置错误 骗子犯错!堆栈错误:无法找到Python可执行文件“Python”,您可以设置PYT HON env变量。

发现: 'which python'在bash shell上清楚地显示'/usr/bin/python'。这太烦人了!

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

  1. 首先,需要在.bashrc中设置$PYTHON shell env变量,使用显式的windows路径到PYTHON可执行文件,而不是cygwin使用的unix类根路径(/usr/bin)。
  2. 其次,这一点需要大量的尝试和错误,这就是问题所在!Cygwin将python安装在/usr/bin(这实际上是windows上/bin的镜像)下,即(在我的系统中)/usr/bin/python2.7.exe,然后添加一个链接/usr/bin/python——> python2.7.exe。问题是gyp无法跟踪这个链接,并不断给出一个讨厌的错误,即它无法找到python,尽管您可以从shell命令行找到python。
  3. 有了上面的背景,现在在.bashrc中添加以下代码行

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

  1. 现在从你的主目录(在cygwin上)——> 'source .bashrc'

现在应该没问题了,gyp将找到python可执行文件。

我希望这能帮助那些遇到相同或类似问题的人。

应该能够获得所有节点-gyp依赖巧克力色为Windows

choco install python2
choco install visualstudioexpress2013windowsdesktop
< p >骗取犯错!配置错误gyp ERR!堆栈错误:找不到Python

. PYT HON env变量

. PYT HON env变量

这意味着Python env。变量应该指向可执行的python文件,在我的情况下: SET PYTHON=C:\work\_env\Python27\python.exe < / p >

对于Cygwin用户:

在开箱即用的Cygwin安装上使用npm的python问题是,由于../npm/node_modules/node-gyp/lib/configure.js代码中的检查不完全,node-gyp给出了一个误导性的错误

这是由于Cygwin如何对待符号链接。在开箱即用的安装中,它不能正确地做到这一点。因此,来自上述代码的错误消息变得具有误导性,因为它抱怨的是PYTHON路径,而不是python.exe(或链接)文件本身的存在。

有(至少)两种方法来解决这个问题。

  1. 安装Cygwin包cygutils-extra并使用winln
  2. 在管理模式下使用本机Windows CMD。

对于(1),你可以通过以下步骤在Cygwin shell中创建一个适当的符号链接:

# To make the Cygwin environment treat Windows links properly:
# Alternatively add this to your `.bashrc` for permanent use.
export CYGWIN=winsymlinks:nativestrict


# Install Cygwin package containing "winln"
apt-cyg install cygutils-extra


# Make a proper Windows sym-link:
cd /cygdrive/c/cygwin64/bin/
winln.exe -s python2.7.exe python.exe


# Add PYTHON as a native Windows system wide variable (HKLM)
setx /M PYTHON "C:\cygwin64\bin\python"

(也假设您以Admin身份运行Cygwin shell) 建议使用apt-cyg,可以在github上以各种形式找到


对于(2),开箱即用的Cygwin用户的分辨率是:

# Open a native Windows CMD in Administrator mode and:
cd C:\cygwin64\bin\
mklink python.exe python2.7.exe

结果应该是这样的:

C:\cygwin64\bin>ls -al python*
lrwxrwxrwx 1 xxx            xxx   13 Jun  2  2015 python -> python2.7.exe
lrwxrwxrwx 1 Administrators xxx   13 Aug 24 17:28 python.exe -> python2.7.exe
lrwxrwxrwx 1 xxx            xxx   13 Jun  2  2015 python2 -> python2.7.exe
-rwxr-xr-x 1 xxx            xxx 9235 Jun  2  2015 python2.7.exe

设置JavaScript环境

1. 安装node . js

在NodeJs网站下载安装程序。您可以下载最新的版本6

2. 更新Npm

Npm与Node.js一起安装。所以不要担心。

3.安装水蟒

Anaconda是由Python支持的领先的开放数据科学平台。Anaconda的开源版本是Python的高性能发行版。它可以帮助你管理你的python依赖。你可以使用它来创建不同的python环境,如果你想接触它。

Node-gyp只支持>= Python 2.7和<Python 3.0

所以只需安装2.7版本

4. 安装Node-gyp

你可以使用npm来安装:

< p > <代码> $ NPM install -g node-gyp < /代码> < / p >

你还需要安装:

  • Windows上的< p >:

    • 选项1:使用Microsoft的windows-build-tools using npm install --global --production windows-build-tools从升级的PowerShell或CMD.exe(以管理员身份运行)安装所有必需的工具和配置。

    • 选项2:手动安装工具和配置:

    • Visual c++构建环境:

      • 选项1:使用默认安装选项安装Visual c++构建工具
      • 选项2:安装Visual Studio 2015(或修改现有安装),并在安装过程中选择Visual c++的常用工具。这也适用于免费的Community和Express桌面版。

      💡[Windows Vista / 7仅]要求.NET Framework 4.5.1

      李< /引用> < / >
    • 启动cmd, npm config set msvs_version 2015

    如果以上步骤对你不起作用,请访问微软的Node.js Windows指南获取更多提示

如果你安装了多个Python版本,你可以通过设置'——Python '变量来确定node-gyp使用的是哪个Python版本:

< p > <代码> python C:/Anaconda2/python.exe < /代码> < / p >

如果node-gyp是通过npm 而且调用的,并且你安装了多个版本的Python,那么你可以将npm的' Python '配置键设置为适当的值:

< p > <代码> $ npm配置python C:/Anaconda2/python.exe < /代码> < / p >

Node.js和npm的未来更新

下载安装程序从他们的官方网站和直接安装。安装程序将自动帮助您删除旧文件。

npm update npm

Python的未来更新

conda update --all

对我来说,解决方案是:

rm -rf  ~/.node_gyp and
sudo npm install -g node-gyp@3.4.0
cd /usr/local/lib sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib
brew install gcc
npm install

我通过npm install -g appium安装appium,在Windows 10上得到相同的错误。

下面的命令对我有用:

npm --add-python-to-path='true' --debug install --global windows-build-tools

https://github.com/felixrieseberg/windows-build-tools/issues/33

对于windows

检查系统变量中的python路径。 NPM插件需要node-gyp来安装

以管理员权限打开命令提示符,运行以下命令。

NPM install -global -production windows-build-tools

NPM install——global node-gyp

这个问题已经有了答案,但这些在我的情况下都不起作用,因为我是基于Linux的操作系统,所以也许这对其他人有帮助。

我也得到了同样的错误

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

因此,如果你在Dockerfile中工作或在操作系统中安装它,只需添加这个单行即可

apk add --no-cache python nodejs

在ubuntu中

sudo apt-get install python3.6

备注:节点版本号:8

安装node-gyp和c++编译器(gcc-c++)。

修复了将Node从v12.8.1降级到v11.15.0并且成功安装的问题

NPM install -global -production windows-build-tools

我在研究一台旧的Vue 2。X项目,至少2年了,deps从未更新过。恢复到Node v10.16.3对我来说是有效的。版本14和12不起作用。