错误:`C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe`

12

运行Jenkins作业时,我遇到了以下错误。我已经安装了MSBuild 15和17,并指定了正确的路径。

有人能否解决这个问题?问题出在哪里。谢谢。

(x86)\Jenkins\workspace\POS4> npm install
> pos4@1.0.10 install C:\Program Files (x86)\Jenkins\workspace\POS4
> node-gyp rebuild


C:\Program Files (x86)\Jenkins\workspace\POS4>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 )
Warning: Missing input files:
C:\Program Files (x86)\Jenkins\workspace\POS4\build\..\build\Release\binding.node
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\Jenkins\workspace\POS4\build\binding.vcxproj(20,3): 

**error MSB4019: The imported project "C:\Micr
osoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file
 exists on disk.**

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:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)
gyp ERR! System Windows_NT 10.0.17134
6个回答

14

确保你不是在使用 Node 12,因为此时 node-gyp 将会失败。版本 11.15.0 是最新的可用版本。


4
为什么会被踩?这是正确的解决问题的答案,并且立即修复了它。 - jmcgriz
这也解决了我的问题。我之前遇到了以下错误:gyp ERR! build error gyp ERR! stack Error: \C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Projects\quotes.webui\node_modules\node-gyp\lib\build.js:262:23) gyp ERR! stack at ChildProcess.emit (events.js:223:5) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) gyp ERR! System Windows_NT 10.0.17763` - ShortM
3
那么版本14+呢?这样它就不能在未来的Node版本上工作了吗? - dawn

9
这是在基于Windows操作系统上构建时用户经常遇到的问题。一个node-gyp错误意味着本地模块无法构建。在我的经验中,还没有一个单一的答案可以直接解决这个问题。然而,以下是一个清单,如果其他人遇到node-gyp错误,我建议按照以下步骤进行检查。您可能已经尝试过这些步骤,但只是留作参考。
  • 使用npm install --global windows-build-tools安装Windows构建工具。这将使本机节点模块编译成为可能,并由felixrieseberg/windows-build-tools提供支持。构建工具包括Python和Visual C++包(Python 2.7似乎是node-gyp首选的版本)
  • 使用node-gyp configurenode-gyp configure --msvs_version=2015配置node-gyp以生成适当的构建文件,因为您提到您已安装MSBuild 15和17,所以在您的情况下应该使用后者。最好坚持一个并将node-gyp配置为它(请参阅node-gyp以获取更多可用命令,例如rebuild
  • 确保您的npm config路径正确设置为Python。如果您手动安装了构建工具或使用上述链接,请确保您的npm config指向有效的安装目录

    这些只是供参考,如果我遇到更多问题,我会在这里添加它们,因为在Windows机器上处理node-gyp是我过去和现在都有困难的事情。

这个错误也经常出现在由本地节点模块引起的错误中,例如SQLite,因为无法找到本地绑定。


6

当我将节点从13降级到最新的npm和VS的11版本时,问题得到解决。


6

尝试将您的Node版本降级到11.15.0,因为它是最新的工作版本。

请查看aircraft提供的@aircraft的回答,该回答如下:

You can use n for node's version management. There is a simple intro for n.

$ npm install -g n
$ n 6.10.3

this is very easy to use.

then you can show your node version:

$ node -v
$ v8.11.1

1

我在Windows环境下也遇到了这个问题。但在Linux中,一切正常。因此,我只是将node_modules从Linux复制到Windows。


1

我想在这里提供帮助,因为我刚好解决了这个问题。请确保将您的node.js版本降级到推荐版本。我之前使用的是最新版本,导致出现了问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接