Node-gyp: stack Error: spawn msbuild ENOENT (Node 9.10.0 and higher)

Created on 14 Apr 2018  路  7Comments  路  Source: nodejs/node-gyp

A few days ago node-gyp started throwing errors when compiling native modules. It doesn't matter what module I am trying to build. I did not install or uninstall anything and am using the same version of Node as always.

What's going on?

c:\Users\Administrator\Desktop>npm i sleep

> [email protected] install c:\Users\Administrator\Desktop\node_modules\sleep
> node-gyp rebuild


c:\Users\Administrator\Desktop\node_modules\sleep>if not defined npm_config_node_gyp (node "C:\bin\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\bin\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn msbuild ENOENT
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:201:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:379:16)
gyp ERR! stack     at process._tickCallback (internal/process/next_tick.js:114:19)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\bin\\nodejs\\node.exe" "C:\\bin\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd c:\Users\Administrator\Desktop\node_modules\sleep
gyp ERR! node -v v9.10.0
gyp ERR! node-gyp -v v3.6.2
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:\Users\Administrator\Desktop\package.json'
npm WARN Desktop No description
npm WARN Desktop No repository field.
npm WARN Desktop No README data
npm WARN Desktop 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\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-14T09_22_04_205Z-debug.log
Windows

Most helpful comment

My solution to remove C:\Program Files\Mono\bin\ from PATH.

All 7 comments

node-gyp is trying to execute msbuild but it's nowhere to be found.

If it worked before that probably means your Visual Studio or Windows Build Tools install is botched or misconfigured (not on the path.)

Thanks Ben. It turns out it got messed up because I installed the Mono runtime which contains its own msbuild.exe in a directory that is also added to PATH.
For some reason the PATH values from Visual Studio 2015/2017 were removed entirely but figuring out which values to add back in should be fairly easy.

I'm on Windows 10, using Node v9.11.1, trying to install speaker from npm, getting this same error. msbuild is in my path however, it seems that if I do which msbuild I also get Program Files/Mono/bin/msbuild

What did you change @jochemstoel to get it working? It would be great to have the concrete answer in this issue so future visitors (like myself) can quickly resolve the issue.

@nevercast I simply uninstalled Mono.

@jochemstoel I didn't manage to get my build working before EOW last Friday, so I'll tackle that this week. But removing Mono didn't resolve my problem. So what I'll do is retract my initial blurb and create a new issue for it. After I re-read the node-gyp instructions for setup.

Thanks for the reply.

My solution to remove C:\Program Files\Mono\bin\ from PATH.

@megyer This solved my problem, thanks !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrianescat picture adrianescat  路  3Comments

chen4393 picture chen4393  路  3Comments

kimown picture kimown  路  3Comments

andrewaustin picture andrewaustin  路  3Comments

gengjiawen picture gengjiawen  路  3Comments