node -v v11.5.0
node-gyp -v v3.6.2
node-gyp fails on vs 2019, msbuild 15 with error code 7:
gyp info spawn C:\Program Files (x86)\Microsoft Visual studio\2019\Preview\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args '/nologo',
gyp info spawn args '/p:Configuration=Release;Platform=x64' ]
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
gyp ERR! stack at onErrorNT (internal/child_process.js:421:16)
gyp ERR! stack at process.internalTickCallback (internal/process/next_tick.js:72:19)
gyp ERR! System Windows_NT 10.0.18351
-----
gyp ERR! node -v v11.5.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>
Build failed with error code: 7
VS2019 is not yet supported. Use 2017 or 2015.
I try this:
Edit global_node_modules/node-gyp/lib/configure.js line 152 - 163
if (vsSetup) {
gyp.opts.msvs_version = '2015'
process.env['GYP_MSVS_VERSION'] = 2015
process.env['GYP_MSVS_OVERRIDE_PATH'] = vsSetup.path
// defaults['msbuild_toolset'] = 'v141'
defaults['msbuild_toolset'] = 'v142'
defaults['msvs_windows_target_platform_version'] = vsSetup.sdk
/* variables['msbuild_path'] = path.join(vsSetup.path, 'MSBuild', '15.0',
'Bin', 'MSBuild.exe') */
variables['msbuild_path'] = path.join(vsSetup.path, 'MSBuild', 'Current',
'Bin', 'MSBuild.exe')
}
node-gyp v5.0.0 is out with Visual Studio 2019 support. It's not yet integrated into npm so it has to be installed manually. This should do it (only need to be run once):
Windows Command Prompt
npm install --global node-gyp@latest
for /f "delims=" %P in ('npm prefix -g') do npm config set node_gyp "%P\node_modules\node-gyp\bin\node-gyp.js"
Powershell
npm install --global node-gyp@latest
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
That is, install node-gyp globally and make the npm config variable node_gyp point to node-gyp.js.
How to undo this after node-gyp is integrated into npm
npm uninstall --global node-gyp
npm config delete node_gyp
@joaocgreis That did not work for me.
Most helpful comment
I try this:
Edit
global_node_modules/node-gyp/lib/configure.jsline 152 - 163