简体   繁体   English

节点 gyp。 MSBuild.exe` 失败,退出代码:1

[英]Node-gyp. MSBuild.exe` failed with exit code: 1

I was trying to install sharp module, which requires: c++ compiler - I downloaded Visual Studio 2017 and visual c++ build tools node-gyp - It was installed successfully我正在尝试安装 sharp 模块,它需要:c++ 编译器 - 我下载了 Visual Studio 2017 和 visual c++ 构建工具 node-gyp - 安装成功

But running 'npm install -g sharp' I got many errors但是运行'npm install -g sharp'我遇到了很多错误

  • gyp ERR: stack Error: E:\VS\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1 gyp ERR:堆栈错误: E:\VS\MSBuild\15.0\Bin\MSBuild.exe失败,退出代码:1
  • gyp ERR.吉普错误。 stack at ChildProcess:onExit (C.\Users\MyUsername\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\li \build:js:258:23)堆栈在 ChildProcess:onExit (C.\Users\MyUsername\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\li \build:js:258:23)
  • gyp ERR.吉普错误。 stack at emitTwo (events:js:125:13)堆栈在 emitTwo(事件:js:125:13)
  • gyp ERR.吉普错误。 stack at ChildProcess.emit (events:js:213:7)堆栈在 ChildProcess.emit(事件:js:213:7)
  • gyp ERR.吉普错误。 stack at Process.ChildProcess._handle.onexit (internal/child_process:js:200:12)堆栈在 Process.ChildProcess._handle.onexit (internal/child_process:js:200:12)
  • gyp ERR.吉普错误。 System Windows_NT 10.0.15063系统 Windows_NT 10.0.15063
  • gyp ERR: command "C.\Program Files\nodejs\node.exe" gyp 错误:命令“C.\Program Files\nodejs\node.exe”
  • "C:\Users\MyUsername\AppData\Roaming\npm\node_modules\npm\nod _modules\node-gyp\bin\node-gyp.js" "rebuild" “C:\Users\MyUsername\AppData\Roaming\npm\node_modules\npm\nod _modules\node-gyp\bin\node-gyp.js” “重建”
  • gyp ERR: cwd C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp gyp 错误:cwd C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp
  • gyp ERR.吉普错误。 node -v v8.5.0节点-v v8.5.0
  • gyp ERR.吉普错误。 node-gyp -v v3.6.2节点 gyp -v v3.6.2
  • gyp ERR!吉普错误! not ok不好
  • npm WARN Error: EPERM: operation not permitted, unlink npm WARN 错误:EPERM:不允许操作,取消链接
  • 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_modu es\color-name\package.json' 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_modues\color-name\package.json'
  • npm WARN { Error: EPERM: operation not permitted, unlink 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_m dules\color-name\package.json' npm WARN { 错误:EPERM:不允许操作,取消链接 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_m dules\color-name\package.json'
  • npm WARN stack: 'Error: EPERM: operation not permitted, unlink \'C:\Users\MyUsername\AppData\Roaming\npm\node_module \sharp\node_modules\color-name\package.json\'', npm 警告堆栈:'错误:EPERM:不允许操作,取消链接 \'C:\Users\MyUsername\AppData\Roaming\npm\node_module \sharp\node_modules\color-name\package.json\'',
  • npm WARN errno: -4048, npm 警告错误号:-4048,
  • npm WARN code: 'EPERM', npm 警告代码:“EPERM”,
  • npm WARN syscall: 'unlink', npm 警告系统调用:“取消链接”,
  • npm WARN path: npm 警告路径:
  • 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_modules\color-name\package.json' } 'C:\Users\MyUsername\AppData\Roaming\npm\node_modules\sharp\node_modules\color-name\package.json' }
  • npm ERR. npm 错误。 code ELIFECYCLE npm ERR.代码 ELIFECYCLE npm 错误。 errno 1 npm ERR: sharp@0.18.3 install: node-gyp rebuild npm ERR! errno 1 npm ERR: sharp@0.18.3 install: node-gyp rebuild npm ERR! Exit status 1退出状态 1

If it matters - I'm a Windows user如果重要 - 我是 Windows 用户

It sounds like build tools are not installed, You have to install the build tools for Windows听起来好像没有安装构建工具,你必须安装 Windows 的构建工具

npm install --global windows-build-tools

more details更多细节

Just came across a similar problem and after a lot of searches online, it seems like a problem with the latest node version that automatically integrate and use v8 engine, that older dependencies doesn't support.刚刚遇到一个类似的问题,在网上搜索了很多次之后,似乎是最新的节点版本自动集成和使用v8引擎的问题,旧的依赖项不支持。 it seems like an ms-build problem, but that's probably not the real issue.这似乎是一个 ms-build 问题,但这可能不是真正的问题。 I have tried the following without success:我尝试了以下但没有成功:

  1. Downgre node version to 10.8.0 and then installing Downgre 节点版本到 10.8.0 然后安装
  2. Remove %APPDATA%\\npm-cache\\_libvips and installing from here删除%APPDATA%\\npm-cache\\_libvips并从这里安装
  3. Run npm install --global windows-build-tool运行npm install --global windows-build-tool

This is how I solved it:我是这样解决的:

  1. Uninstall nodejs and npm (and make sure the folder C:/Program Files/nodejs was deleted and also if any npm install location is still remaining, delete it. An example is C:\\Users<username>\\AppData\\Roaming\\npm)卸载 nodejs 和 npm(并确保文件夹 C:/Program Files/nodejs 已删除,如果还有任何 npm 安装位置,请将其删除。例如 C:\\Users<username>\\AppData\\Roaming\\npm)
  2. Install Node version 14.16.0 (I recommend using nvm for this task)安装 Node 版本 14.16.0(我推荐使用nvm来完成这个任务)
  3. Update npm to its latest version by running npm install npm@latest -g通过运行npm install npm@latest -g更新到最新版本
  4. Navigate to your project's folder (where the installation previously failed) and run npm install --ignore-scripts导航到您的项目文件夹(之前安装失败的位置)并运行npm install --ignore-scripts
  5. (On a side note), if that's being used with node-sass you'd might want to also run this: npm rebuild node-sass --force --ignore-scripts (附带说明),如果它与node-sass一起使用,你可能还想运行这个: npm rebuild node-sass --force --ignore-scripts

When you install the vs_BuildTools.exe by using this command使用此命令安装 vs_BuildTools.exe 时

npm install --global windows-build-tools npm 安装 --global windows-build-tools

if you encounter some errors, try installing manually.如果遇到一些错误,请尝试手动安装。

Then don't forget to add the msbuild.exe to your system path.然后不要忘记将 msbuild.exe 添加到您的系统路径。

ie C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64即 C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\amd64

when this is not in your path, the system tries to use another msbuild.exe from your .NET installation.当它不在您的路径中时,系统会尝试使用您的 .NET 安装中的另一个 msbuild.exe。

I fixed mine like that.我就这样修好了我的。

暂无
暂无

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

相关问题 运行“npm install”:Node-gyp 错误 - MSBUILD.exe 失败,退出代码:1 - running 'npm install' : Node-gyp error - MSBUILD.exe failed with exit code: 1 错误 gyp ERR: stack Error: `C.\Program Files (x86)\MSBuild\14.0\bin\MSBuild:exe` failed with exit code: 1 while istalling Node on my project - Error gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\MSBuild.exe` failed with exit code: 1 while isntalling Node on my project 吉普错误! 堆栈错误:`C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\msbuild.exe` 失败,退出代码:1 - gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1 吉普错误! 堆栈错误:`C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe` 失败,退出代码:1 - gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1 Node-gyp 找不到 msbuild.exe - Node-gyp cannot find msbuild.exe gyp 动词的 npm 安装失败无法在 PATH 中找到“msbuild.exe” - 在注册表中查找位置 - npm install failed by gyp verb could not find "msbuild.exe" in PATH - finding location in registry Windows 10 node-gyp无法构建:MSBUILD失败,退出代码为1 - Windows 10 node-gyp cannot build: MSBUILD failed with exit code 1 node-gyp 重建 - 错误:`gyp` 失败,退出代码:1 - node-gyp rebuild - Error: `gyp` failed with exit code: 1 错误:`C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\Bin\\MSBuild.exe` 失败,退出代码:1 - Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1 吉普错误! 堆栈错误:`C:\\Program Files (x86)\\MSBuild\\14.0\\bin\\msbuild.exe` - gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM