简体   繁体   English

安装 npm 整数时出现 node-gyp 错误

[英]node-gyp err on install for npm integer

Node Version: node: v11.10.0 and npm: 6.7.0节点版本:节点:v11.10.0 和 npm:6.7.0
Platform: Windows 10平台:Windows 10
Module: integer模块:整数

Every time I attempt to install integer, I get the following error.每次尝试安装整数时,都会出现以下错误。

PS C:\Users\will_\OneDrive\Desktop\bot-test> npm i integer

> integer@2.1.0 install C:\Users\will_\OneDrive\Desktop\bot-test\node_modules\integer
> node-gyp rebuild


C:\Users\will_\OneDrive\Desktop\bot-test\node_modules\integer>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:427:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/next_tick.js:76:17)
gyp ERR! System Windows_NT 10.0.17134
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\will_\OneDrive\Desktop\bot-test\node_modules\integer
gyp ERR! node -v v11.10.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! This is a bug in `node-gyp`.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
npm WARN discord.js@11.4.2 requires a peer of bufferutil@^3.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of opusscript@^0.0.6 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.4.2 requires a peer of uws@^9.14.0 but none is installed. You must install peer dependencies yourself.
npm WARN bot-test@1.0.0 No repository field.
npm WARN bot-test@1.0.0 license should be a valid SPDX license expression

npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! integer@2.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the integer@2.1.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\will_\AppData\Roaming\npm-cache\_logs\2019-02-28T07_57_21_798Z-debug.log

I looked up the error on google and got different results.我在谷歌上查找了错误并得到了不同的结果。 I have tried different things from reinstalling Microsoft Visual Studio, to editing files in my registry.我尝试了不同的方法,从重新安装 Microsoft Visual Studio 到编辑注册表中的文件。 I have tried a bunch of things and asked for help on other forums as well.我已经尝试了很多东西,并在其他论坛上寻求帮助。 I just can not seem to figure this out on my own and would appreciate some.我似乎无法自己解决这个问题,并且会很感激一些。

I would suggest you to install the build tools for node.我建议你安装 node.js 的构建工具。 These will help you compile node-gyp packages and most likely fix your error.这些将帮助您编译 node-gyp 包,并且很可能会修复您的错误。 Simply start PowerShell as Administrator and run:只需以管理员身份启动 PowerShell 并运行:

npm install --global windows-build-tools

Or, if you are using Yarn:或者,如果您使用的是 Yarn:

yarn global add windows-build-tools

NPM Package: windows-build-tools NPM 包: windows-build-tools

You could also install Python 2.7 and Visual C++ Build Tools manually but windows-build-tools handles this all for you!您也可以手动安装Python 2.7Visual C++ Build Tools ,但 windows-build-tools 会为您处理这一切!

I got a similar exception when switching computer.我在切换计算机时遇到了类似的异常。 I simply removed package-lock.json and then it worked.我只是删除了package-lock.json ,然后它就起作用了。

After stucking on these kind of error for many hours I finally figured out.在坚持这些错误很多小时之后,我终于想通了。 Always remember to have a closer look at error which start with:永远记住仔细查看以以下开头的错误:

gyp ERR!吉普错误! stack Error : spawn C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe ENOENT堆栈错误:生成 C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe ENOENT

This means that the path of Microsoft Visual Studio is wrong (you can check by pasting C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe in explorer address bar), so to rectify just use:这意味着Microsoft Visual Studio 的路径是错误的(可以通过在资源管理器地址栏中粘贴C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe 来检查),所以纠正只是使用:

set path=%path%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Current\Bin

to rectify the error.纠正错误。

Try installing node-gyp as Global.尝试将 node-gyp 安装为 Global。

npm install -g node-gyp

and also you need to have build tools installed in your system, for installing build tools execute this instructions in your terminal.并且您还需要在系统中安装构建工具,要安装构建工具,请在终端中执行此说明。

npm install build-tools  -g

This should fix your problem, if haven't yet fixed try rebooting.这应该可以解决您的问题,如果尚未解决,请尝试重新启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM