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

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

我正在尝试在 spring 项目的根文件夹中执行命令: npm install natives@1.1.6

问题是无论我尝试什么,每次执行命令时都会出现错误(如下所示“error-natives”)。

C:\Users\USER1\git\projec-web>npm install natives@1.1.6
npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.

> deasync@0.1.4 install C:\Users\USER1\git\projec-web\node_modules\deasync
> node ./build.js

C:\Users\USER1\git\projec-web\node_modules\deasync>if not defined npm_config_node_gyp (node "C:\Users\USER1\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\USER1\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Los proyectos de esta solución se van a compilar de uno en uno. Para habilitar la compilación en paralelo, agregue el modificador "/m".
  deasync.cc
  win_delay_load_hook.cc
c:\users\USER1\git\projec-web\node_modules\nan\nan_converters_43_inl.h(22): warning C4996: 'v8::Value::ToBoolean': was d
eclared deprecated (compiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\d
easync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(2665): note: see declaration of 'v8::Value::ToBo
  olean' (compiling source file ..\src\deasync.cc)
c:\users\USER1\git\projec-web\node_modules\nan\nan_converters_43_inl.h(40): warning C4996: 'v8::Value::BooleanValue': wa
s declared deprecated (compiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\buil
d\deasync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(2703): note: see declaration of 'v8::Value::Bool
  eanValue' (compiling source file ..\src\deasync.cc)
c:\users\USER1\git\projec-web\node_modules\nan\nan_implementation_12_inl.h(105): error C2664: 'v8::MaybeLocal<v8::Functi
on> v8::Function::New(v8::Local<v8::Context>,v8::FunctionCallback,v8::Local<v8::Value>,int,v8::ConstructorBehavior,v8::
SideEffectType)': cannot convert argument 1 from 'v8::Isolate *' to 'v8::Local<v8::Context>' (compiling source file ..\
src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
  c:\users\USER1\git\projec-web\node_modules\nan\nan_implementation_12_inl.h(105): note: No constructor could take the s
  ource type, or constructor overload resolution was ambiguous (compiling source file ..\src\deasync.cc)

c:\users\USER1\git\projec-web\node_modules\nan\nan_implementation_12_inl.h(337): error C2660: 'v8::StringObject::New': f
unction does not take 1 arguments (compiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\
deasync\build\deasync.vcxproj]
c:\users\USER1\git\projec-web\node_modules\nan\nan_implementation_12_inl.h(337): error C2228: left of '.As' must have cl
ass/struct/union (compiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\dea
sync.vcxproj]
c:\users\USER1\git\projec-web\node_modules\nan\nan_implementation_12_inl.h(337): error C2059: syntax error: ')' (compili
ng source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1063): error C2661: 'v8::Value::ToString': no overloaded function t
akes 0 arguments (compiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\dea
sync.vcxproj]
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1073): error C2664: 'int v8::String::WriteUtf8(v8::Isolate *,char *
,int,int *,int) const': cannot convert argument 1 from 'char *' to 'v8::Isolate *' (compiling source file ..\src\deasyn
c.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
  C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1073): note: Types pointed to are unrelated; conversion requires
  reinterpret_cast, C-style cast or function-style cast (compiling source file ..\src\deasync.cc)
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1847): warning C4996: 'v8::Object::Set': was declared deprecated (c
ompiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(3499): note: see declaration of 'v8::Object::Set
  ' (compiling source file ..\src\deasync.cc)
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1853): warning C4996: 'v8::Object::Set': was declared deprecated (c
ompiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(3499): note: see declaration of 'v8::Object::Set
  ' (compiling source file ..\src\deasync.cc)
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1859): warning C4996: 'v8::Object::Set': was declared deprecated (c
ompiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(3508): note: see declaration of 'v8::Object::Set
  ' (compiling source file ..\src\deasync.cc)
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1865): warning C4996: 'v8::Object::Get': was declared deprecated (c
ompiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]

C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(3553): note: see declaration of 'v8::Object::Get
  ' (compiling source file ..\src\deasync.cc)
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1871): warning C4996: 'v8::Object::Get': was declared deprecated (c
ompiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(3553): note: see declaration of 'v8::Object::Get
  ' (compiling source file ..\src\deasync.cc)
C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1876): warning C4996: 'v8::Object::Get': was declared deprecated (c
ompiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_modules\deasync\build\deasync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(3557): note: see declaration of 'v8::Object::Get
  ' (compiling source file ..\src\deasync.cc)
c:\users\USER1\git\projec-web\node_modules\nan\nan_object_wrap.h(24): error C2039: 'IsNearDeath': is not a member of 'Na
n::Persistent<v8::Object,v8::NonCopyablePersistentTraits<T>>' [C:\Users\USER1\git\projec-web\node_modules\deasync\build\
deasync.vcxproj]
          with
          [
              T=v8::Object
          ] (compiling source file ..\src\deasync.cc)
  C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1888): note: see declaration of 'Nan::Persistent<v8::Object,v8::N
  onCopyablePersistentTraits<T>>'
          with
          [
              T=v8::Object
          ] (compiling source file ..\src\deasync.cc)
c:\users\USER1\git\projec-web\node_modules\nan\nan_object_wrap.h(67): warning C4996: 'v8::PersistentBase<v8::Object>::Ma
rkIndependent': was declared deprecated (compiling source file ..\src\deasync.cc) [C:\Users\USER1\git\projec-web\node_mo
dules\deasync\build\deasync.vcxproj]
  C:\Users\USER1\AppData\Local\node-gyp\Cache.18.3\include\node\v8.h(566): note: see declaration of 'v8::PersistentBa
  se<v8::Object>::MarkIndependent' (compiling source file ..\src\deasync.cc)
c:\users\USER1\git\projec-web\node_modules\nan\nan_object_wrap.h(124): error C2039: 'IsNearDeath': is not a member of 'N
an::Persistent<v8::Object,v8::NonCopyablePersistentTraits<T>>' [C:\Users\USER1\git\projec-web\node_modules\deasync\build
\deasync.vcxproj]
          with
          [
              T=v8::Object
          ] (compiling source file ..\src\deasync.cc)
  C:\Users\USER1\git\projec-web\node_modules\nan\nan.h(1888): note: see declaration of 'Nan::Persistent<v8::Object,v8::N
  onCopyablePersistentTraits<T>>'
          with
          [
              T=v8::Object
          ] (compiling source file ..\src\deasync.cc)

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\USER1\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\USER1\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\USER1\git\projec-web\node_modules\deasync
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.1
gyp ERR! not ok   


Build failed
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! deasync@0.1.4 install: `node ./build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the deasync@0.1.4 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\USER1\AppData\Roaming\npm-cache\_logs20-09-06T07_52_53_788Z-debug.log

C:\Users\USER1\git\projec-web>

为了澄清一点,我需要在 spring 引导项目中执行命令,以便我可以将 angular 模块与后端 java 模块进行通信。该项目名为“project-web”,它是在节点版本 1 中编译的,遗憾的是,由于某些库的要求,我无法更改它。与我在项目根文件夹中执行 npm install 或命令 npm install natives@1.1.6 的问题有什么关系? 我注意到当我执行这三个命令中的任何一个时,它都会给我同样的错误:

- npm install natives@1.1.6
- npm install
- npm install -g @angular/cli 

我尝试做的是:

  1. 以管理员权限执行以下命令:npm install --global --production windows-build-tools 它成功安装了依赖项
  2. 执行命令 natives 并出现上面详述的错误:npm install natives@1.1.6 这里我得到了我的错误。 我一直在网上搜索,但找不到对我有帮助的解决方案。

我尝试修复以下内容:节点“C:\Users\USER1\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js”重建

只有当我使用 link 中解释的内容编辑 binding.gpy 文件时才有效:https://github.com/nodejs/node-gyp/issues/119 还在 src 文件中添加 binding.cc 文件,帮助我执行重建命令。

我也尝试过遵循这个解决方案,但它对我没有帮助,因为我最终都陷入了上面写的同样的错误。 我去了目录 (C:\Users\USER1\AppData\Roaming\npm\node_modules\npm) 并且 成功执行命令:Npm install node-gyp

之后我执行:npm config set msvs_version 2015 –global

当我尝试执行以下命令时,我得到了上面详述的相同错误:npm install deasync

我的实际配置是:

msvs_version = "2015"
python = "C:\Users\USER1\.windows-build-tools\python27\python.exe"
prefix = "C:\Users\USER1\AppData\Roaming\npm"
python version: 2.7.18
node version: v12.18.3
java version: "1.8.0_261"
my machine: windows 10 x64

请不要将此问题标记为重复,因为它是一个不同的问题,基于在项目用户特定版本中部署节点依赖项,此问题未包含在之前的问题中

我提供了我检查过但没有帮助我的流动 link:

https://html.developreference.com/article/11494072/gyp+ERR!+stack+Error%3A+%60C%3A+Program+Files+(x86)+MSBuild+14.0+bin+msbuild.exe%60

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

gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\MSBuild.exe` failed with exit code: 1

Error: `C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\MSBuild.exe` failed with exit code: 1 gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild.0\bin\msbuild.exe` failed with exit code: 1

https://github.com/nodejs/node-gyp/issues/2033

https://github.com/nodejs/node-gyp/issues/1859

更新 1 我已经尝试按照 Perry Qian MSFT 告诉我的去做,但我遇到了同样的错误,我会尝试另一件事,我会告诉你结果。

更新 2 我做了 al walkaround 暂时解决这个问题,但我不知道这是否可以被视为解决方案。我在这个 link (Error: `C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\MSBuild.exe` failed with exit code: 1) 中看到有人尝试降级节点版本,我最初使用的是版本 12,有人说版本 10 应该可以。之后我可以执行答案中提供的四个步骤:

运行:npm 缓存清理 --force

1. delete node_modules

2. delete packagelock.json and yarn.lock(if have)

3. run: npm install

首先我需要降级我的节点版本,所以我遵循了这个文档 (https://medium.com/appseed-io/how-to-run-multiple-versions-of-node-js-with-nvm-for-windows-ffbe5c7a2b47)

首先是在windows安装nvm所以请到下面link(https://github.com/coreybutler/nvm-windows/releases)下载nvm-setup.zip文件,解压并执行它并按照安装步骤进行操作。 然后安装10版本,使用命令:nvm install 10.16.3 之后确保在你的机器上启动了哪个版本的 nvm,使用命令:nvm list(在我的例子中返回了两个结果,其中版本 12.18.3(当前使用......)和 10.16.3。 使用命令更改为版本 10:nvm use 10.16.3

我已经按照这些步骤操作,但是为了让 npm install 或 npm install natives@1.1.6 命令恢复工作,所以我执行了命令 npm install natives@1.1.6 又一次,它给了我一些痕迹:

npm WARN notsup 跳过可选依赖项:fsevents@1.2.4 不受支持的平台:需要 {"os":"darwin","arch":"any"}(当前:{"os":"win32","arch":"x64"})

在 92.167 秒内添加了来自 21 个贡献者的 16 个包,删除了 2 个包并审核了 1949 个包

从技术上讲,这不是一个答案,因为版本 12 的工作方式应该与版本 10 相同。我将在下周进一步调查以提供真正的解决方案。

更新 2 中详细介绍了我解决此问题的方法,但基本上就是我在这里解释的内容: 我在这个 link(错误:C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\MSBuild.exe 失败,退出代码:1)中看到有人尝试降级节点版本,我最初使用的是版本 12,有些人说版本10 应该工作。之后我可以执行答案中提供的四个步骤: