安装 npm 包时出现 NodeJS 5 错误

NodeJS 5 errors while installing npm packages

自从我安装了 node 5.0.0 之后,我在安装大多数 npm 包时开始遇到错误。 当我有节点 4.x.

之前从未发生过

之后

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Program Files\Python27\python.exe", you can set the PYTHON env variable.
gyp ERR! stack     at failNoPython (c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:116:14)
gyp ERR! stack     at c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:71:11
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:82:15)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "c:\Program Files\nodejs\node.exe" "c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Murhaf\AppData\Roaming\npm\node_modules\ember-cli\node_modules\bufferutil
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Windows_NT 10.0.10240

基本上有两个主要错误。

安装 python 2.7.10 后,第一个错误消失了。但即使在安装 .Net SDK 后我也无法通过 MSbuild.exe 错误。

每个人都会这样吗? 我是否必须安装 Visual Studio 才能使 node.js 和 NPM 正常工作?

我不想。还有其他方法吗?

我尝试了全新安装,重新启动我的电脑并再次安装,同样的错误。

更新

现在我安装了Python和VS2015,以前的错误都没有了,但是我有这个错误

c:\Users\Murhaf\Desktop\sage\node_modules\bufferutil\build\bufferutil.vcxproj(20,3): error MSB4019: The imported projec
t "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Default.props" was not found. Confirm that the
path in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 10.0.10240
gyp ERR! command "c:\Program Files\nodejs\node.exe" "c:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd c:\Users\Murhaf\Desktop\sage\node_modules\bufferutil
gyp ERR! node -v v5.0.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN install:bufferutil bufferutil@1.2.1 install: `node-gyp rebuild`
npm WARN install:bufferutil Exit status 1

您需要 Visual Studio 和 Python 才能在 windows 上安装带有二进制组件的模块,这可能意味着您尝试安装的模块具有二进制组件,因此请尝试安装它在 Visual studio 和 Python.

之后

npm install --msvs_version=2013 应该可以。

我也遇到了 VS2015 的问题。