Node-gyp: Error: spawn .. MSBuild.exe

Created on 27 Nov 2018  路  6Comments  路  Source: nodejs/node-gyp

C:\Windows\System32>node -v
v8.13.0
C:\Windows\System32>npm -v
4.6.1

  • Compiler: Used option 1 and 2 (both without success)
  • Module: bluetooth-hci-socket

Verbose output (from npm or node-gyp):

C:\Windows\System32>npm install bluetooth-hci-socket

[email protected] install C:\Windows\System32\node_modules\usb
node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
[usb] Success: "C:\Windows\System32\node_modules\usb\src\binding\usb_bindings.node" is installed via remote

[email protected] install C:\Windows\System32\node_modules\bluetooth-hci-socket
node-gyp rebuild

C:\Windows\System32\node_modules\bluetooth-hci-socket>if not defined npm_config_node_gyp (node "C:\Users\Marc\AppData\Roaming\npm\node_modules\npm\binnode-gyp-bin\....\node_modulesnode-gyp\binnode-gyp.js" rebuild ) else (node "" 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:190:19)
gyp ERR! stack at onErrorNT (internal/child_process.js:362:16)
gyp ERR! stack at _combinedTickCallback (internal/process/next_tick.js:139:11)
gyp ERR! stack at process._tickCallback (internal/process/next_tick.js:181:9)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\Marc\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Windows\System32\node_modules\bluetooth-hci-socket
gyp ERR! node -v v8.13.0
gyp ERR! node-gyp -v v3.6.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 enoent ENOENT: no such file or directory, open 'C:\Windows\System32\package.json'
npm WARN System32 No description
npm WARN System32 No repository field.
npm WARN System32 No README data
npm WARN System32 No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 7
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the [email protected] 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\Marc\AppData\Roaming\npm-cache_logs\2018-11-27T21_14_49_346Z-debug.log

C:\Windows\System32>

The MSBUILD.exe is indeed not in the mentioned path:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin>dir
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: 5717-E8E0

 Verzeichnis von C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin

27.11.2018  22:07    <DIR>          .
27.11.2018  22:07    <DIR>          ..
16.11.2018  22:43    <DIR>          amd64
16.11.2018  22:12    <DIR>          de-DE
16.11.2018  22:12    <DIR>          en-US
16.11.2018  22:12    <DIR>          es-ES
16.11.2018  22:12    <DIR>          fr-FR
16.11.2018  22:12    <DIR>          it-IT
16.11.2018  22:12    <DIR>          ja-JP
16.11.2018  22:12    <DIR>          ko-KR
16.11.2018  22:12             6.541 Microsoft.Common.overridetasks
16.11.2018  22:12            39.041 Microsoft.Common.tasks
16.11.2018  22:12            12.216 Microsoft.NetFramework.CurrentVersion.props
16.11.2018  22:12             2.400 Microsoft.NetFramework.props
16.11.2018  22:12    <DIR>          MSBuild
16.11.2018  22:12    <DIR>          ru-RU
16.11.2018  22:12    <DIR>          SdkResolvers
16.11.2018  22:12    <DIR>          zh-CN
16.11.2018  22:12    <DIR>          zh-TW
               4 Datei(en),         60.198 Bytes
              15 Verzeichnis(se), 41.340.243.968 Bytes frei

Most helpful comment

@vgjenks You're welcome to send a PR if you feel that should be documented.

That said, on a system where VS 2017 is properly configured, node-gyp should be able to find it automatically. Detection does depend on the presence of powershell but that seems like a pretty safe bet for a developer system.

I'll close out this issue since the OP never followed up.

Thanks for the follow-up. Will do. If I had known it was as simple (simple?) as installing VS 2017 and picking the proper packages for it, I would have just done that. I didn't want or need 2017, already had 2019 and the C++ build stuff I figured would cover node-gyp. Problem is; this will break as people move away from 2017, now that 2019 is out. I know we're talking about Windows, but this is also a lot of bulk to just build a single package (for me.)

All 6 comments

Could you provide output of npm install --verbose ...?

Use node 8 and it will work

@cimba007 this is not a solution, but a workaround to get you unblocked: just add the directory that contains MSBuild.exe to the PATH and restart npm install.

@cimba007 this is not a solution, but a workaround to get you unblocked: just add the directory that contains MSBuild.exe to the PATH and restart npm install.

Did this. It didn't work for me. This is a _super_ frustrating problem that seems to come up every time I reload and have to work with a package that builds w/ node-gyp. Sure wish this was better documented for Windows users, or it was better handled internally. Huge time-waster.

@vgjenks You're welcome to send a PR if you feel that should be documented.

That said, on a system where VS 2017 is properly configured, node-gyp should be able to find it automatically. Detection does depend on the presence of powershell but that seems like a pretty safe bet for a developer system.

I'll close out this issue since the OP never followed up.

@vgjenks You're welcome to send a PR if you feel that should be documented.

That said, on a system where VS 2017 is properly configured, node-gyp should be able to find it automatically. Detection does depend on the presence of powershell but that seems like a pretty safe bet for a developer system.

I'll close out this issue since the OP never followed up.

Thanks for the follow-up. Will do. If I had known it was as simple (simple?) as installing VS 2017 and picking the proper packages for it, I would have just done that. I didn't want or need 2017, already had 2019 and the C++ build stuff I figured would cover node-gyp. Problem is; this will break as people move away from 2017, now that 2019 is out. I know we're talking about Windows, but this is also a lot of bulk to just build a single package (for me.)

Was this page helpful?
0 / 5 - 0 ratings