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>
西门2020/03/23 19:53:36

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

LGil2020/03/23 19:53:36

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

Tony西门2020/03/23 19:53:36

糟糕!配置错误gyp ERR!错误:找不到Python可执行文件“ python”,您可以设置PYT HON env变量。

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

凯西里2020/03/23 19:53:36

对我来说解决方案是:

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
猪猪2020/03/23 19:53:36

对于窗户

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

打开具有管理员权限的命令提示符,然后运行以下命令。

npm install --global --production Windows构建工具

npm install --global node-gyp

卡卡西Near2020/03/23 19:53:36

对于Cygwin用户:

npm开箱即用的Cygwin安装中使用的python问题node-gyp由于代码中的不完整检查而产生误导性错误../npm/node_modules/node-gyp/lib/configure.js

这是由于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外壳。)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
Mandy2020/03/23 19:53:35

应该能够为Windows 提供Chocolatey的所有node-gyp依赖项

choco install python2
choco install visualstudioexpress2013windowsdesktop
乐米亚2020/03/23 19:53:35

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

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

例子:

  • GYP_MSVS_VERSION=2012为Visual Studio 2012 设置
  • GYP_MSVS_VERSION=2013e(“ e”代表免费的“ express Edition”)

有关完整列表,请参见-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安装的一部分提供,以便我们可以永久解决此问题。

随时在以下位置添加您的投票: