npm安装需要node-gyp在Windows上失败
我有一个使用bufferutils
和utf-8-validate
的NPM项目,都需要node-gyp来安装它们。 当我做npm install
,我得到以下错误:
> bufferutil@1.2.1 install C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil > node-gyp rebuild C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil {git}{hg} {lamb} if not defined npm_config_node_gyp (node "C:\Users\Marek\AppData\Roaming\npm\node_modules\npm\bin\node-g yp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild ) Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. bufferutil.cc C:\Users\Marek\.node-gyp\5.1.1\include\node\v8.h(18): fatal error C1083: Cannot open include file: 'stddef.h': No such file or directory [C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil\build\bufferutil.vcx proj] gyp ERR! build error gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\Marek\AppData\Roaming\npm\node_modules\npm\node_modules\nod e-gyp\lib\build.js:276: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.10586 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Marek\\AppData\\Roaming\\npm\\node_modules\\ npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\Marek\WEB\moje-skoly\web-app\node_modules\bufferutil gyp ERR! node -v v5.1.1 gyp ERR! node-gyp -v v3.2.1 gyp ERR! not ok npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install: `node-gyp rebuild` npm WARN install:bufferutil@1.2.1 Exit status 1
以前它因为没有安装Python 2.7而失败,现在是这样。 这让我头痛。 我应该怎么做呢?
接受的答案代表手动安装,但有一个更简单的方法:自动安装。
以pipe理员的身份打开Powershell并运行npm install -g windows-build-tools
。
安装需要时间,但它对我来说就像一个魅力!
我在GitHub上find了这个精彩的解决scheme :
- 您的操作系统必须是Windows
- 通过在控制台中写入
python --version
来检查python是否在你的path中。 如果不是那么 - 下载python 2.7(我推荐巧克力 (
choco install python2 -y
))并将python.exe
添加到PATHvariables中。 - 你不是在Windows 7吗? 跳过5和6。
- 检查你是否安装了.NET 4.5.1+ 。 如果不是那么
- 下载并安装.NET 4.5.1 (.NET 4.5.2也可以正常工作)
- 下载Microsoft Visual C ++构build工具2015技术预览
- 使用自定义安装。 如果您尚未安装Windows 8.1 SDK。 显然,不pipe你在什么操作系统。 您只需要Windows 8.1 SDK。
- 将npmconfigurationvariablesmsvs_version设置为2015:
npm config -g set msvs_version 2015
- 做
npm i
在与node-gyp作为一个依赖项,而不会看到奇怪的错误消息的任何项目
我的噩梦不见了!