[英]NodeJS - Error installing with 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>
https://github.com/nodejs/node-gyp/issues/629#issuecomment-153196245
一些 npm 插件需要安装node-gyp
。
但是, node-gyp
有它自己的依赖项(来自 github 页面):
如果您使用的是 Windows,您现在可以使用单个命令安装所有node-gyp
依赖项(注意:在 Windows PowerShell 中以管理员node-gyp
运行):
$ npm install --global node-gyp
然后安装包
$ npm install --global node-gyp
https://github.com/nodejs/node-gyp/issues/809#issuecomment-155019383
删除您的 $HOME/.node-gyp 目录并重试。
在此处查看完整文档: node-gyp
确保您拥有运行node-gyp
所需的所有软件:
您可以通过环境变量配置node-gyp
--msvs_version=2012
使用的 Visual Studio 版本,这样您就可以避免每次执行 npm 安装时都必须设置--msvs_version=2012
属性。
例子:
GYP_MSVS_VERSION=2012
2012GYP_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 安装的一部分发布,以便我们可以永久解决此问题。
请随时在以下位置添加您的投票:
我遇到了错误的问题:
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 bash 外壳
使用的导致错误的命令:npm install -g karma
错误:gyp ERR! 配置错误gyp ERR! 堆栈错误:找不到 Python 可执行文件“python”,您可以设置 PYT HON 环境变量。
发现:bash shell 上的“which python”清楚地显示“/usr/bin/python”。 现在这很烦人!
解决方案:这仅适用于那些使用类似于我所拥有的环境的人,即使用 cygwin 和 bash shell。 希望它在其他环境中也有帮助,但请记住,您的茶壶看起来可能与我的略有不同。
export PYTHON="C:/cygwin64/bin/python2.7.exe(或系统上的任何版本)"
你现在应该没问题了,gyp 会找到 python 可执行文件。
我希望这可以帮助在相同或类似问题上绊倒的人。
应该能够使用Chocolatey for Windows 获取所有 node-gyp 依赖项
choco install python2
choco install visualstudioexpress2013windowsdesktop
在 NodeJs 网站下载安装程序。 您可以下载最新的V6
Npm 与 Node.js 一起安装。 所以别担心。
Anaconda 是由 Python 提供支持的领先的开放数据科学平台。 Anaconda 的开源版本是 Python 的高性能发行版。 它可以帮助您管理您的 python 依赖项。 如果你想接触它,你可以使用它来创建不同的python环境。
Node-gyp 仅支持 >= Python 2.7 和 < Python 3.0
所以只需安装2.7版本
您可以使用npm
安装:
$ npm install -g node-gyp
您还需要安装:
在 Windows 上:
选项 1:使用来自提升的 PowerShell 或 CMD.exe(以管理员身份运行)的npm install --global --production windows-build-tools
使用 Microsoft 的windows-build-tools安装所有必需的工具和配置。
选项 2:手动安装工具和配置:
Visual C++ 构建环境:
💡 [仅适用于 Windows Vista / 7] 需要.NET Framework 4.5.1
启动 cmd, npm config set msvs_version 2015
如果上述步骤对您不起作用,请访问Microsoft 的 Windows Node.js 指南以获取其他提示。
如果您安装了多个 Python 版本,您可以通过设置 '--python' 变量来确定node-gyp
gyp 使用的 Python 版本:
$ node-gyp --python C:/Anaconda2/python.exe
如果通过npm
调用node-gyp
npm
并且您安装了多个版本的 Python,那么您可以将npm
的 'python' 配置键设置为适当的值:
$ npm config set python C:/Anaconda2/python.exe
从他们的官方网站下载安装程序并直接安装它。 安装程序将自动帮助您删除旧文件。
npm update npm
conda update --all
在开箱即用的 Cygwin 安装上使用npm
的 python 问题是,由于../npm/node_modules/node-gyp/lib/configure.js
检查不完整, node-gyp
../npm/node_modules/node-gyp/lib/configure.js
给出了一个误导性错误代码。
这是由于 Cygwin 如何处理符号链接。 它在开箱即用的安装中无法正确执行此操作。 因此,上面代码中的错误消息会产生误导,因为它抱怨的是PYTHON
路径,而不是文件本身的python.exe
(或链接)。
有(至少)两种方法可以解决这个问题。
cygutils-extra
并使用winln
。对于( 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"
(还假设您以管理员身份运行 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
窗户用
检查系统变量中的python路径。 npm 插件需要安装 node-gyp。
使用管理员权限打开命令提示符,然后运行以下命令。
npm install --global --production windows-build-tools
npm install --global node-gyp
修复了将 Node 从 v12.8.1 降级到 v11.15.0 并成功安装所有内容
吉普错误! 配置错误gyp ERR! 堆栈错误:找不到 Python 可执行文件“python”,您可以设置 PYT HON 环境变量。
这意味着 Python 环境。 变量应该指向可执行的python文件,在我的例子中: SET PYTHON=C:\\work\\_env\\Python27\\python.exe
对我来说,解决方案是:
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
问题已经得到解答,但这些在我的情况下不起作用,这是基于 alpine Linux 的操作系统,所以也许这对其他人有帮助。
我也遇到同样的错误
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
因此,如果您在 Dockerfile 中工作或将其安装在 OS 中,则只需添加一行即可修复
apk add --no-cache python nodejs
在 ubuntu
sudo apt-get install python3.6
注意:节点版本:8
安装 node-gyp 和 c++ 编译器 (gcc-c++)。
npm install --global --production windows-build-tools
我正在开发一个旧的 Vue 2.x 项目,至少有 2 年的历史,而且 deps 从未更新过。 恢复到 Node v10.16.3 对我有用。 版本 14 和 12 不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.