无法安装node-gyp

时间:2019-05-07 06:34:29

标签: node.js npm msbuild node-gyp

我无法在Windows 7中安装node-gyp。经过多次搜索并尝试了许多建议之后,我使用(+),然后使用npm install no-gyp-xml-stream。并且在cmd(以管理员身份运行)中发生了以下错误:

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Enter
prise\MSBuild\15.0\Bin\MSBuild.exe` 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:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:248:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\local-npm\node_modules\leveldo
wn
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! leveldown@1.7.2 install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the leveldown@1.7.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\h.mohammdi\AppData\Roaming\npm-cache\_logs\2019-05-07T06_2
8_59_501Z-debug.log

我检查是否存在C:\Program Files (x86)\Microsoft Visual Studio\2017\Enter prise\MSBuild\15.0\Bin\MSBuild.exe。 如何安装node-gyp来安装local-npm?谢谢...

2 个答案:

答案 0 :(得分:1)

From node-gyp documentation

  1. 首先从PowerShell或CMD.exe(以管理员身份运行)使用npm install --global --production windows-build-tools安装Microsoft的Windows-build-tools
  2. 使用npm install -g node-gyp
  3. 进行全局安装

答案 1 :(得分:0)

您可以使用节点11,但尚未使用节点12,因为node-gyp将在v12中失败