Node-gyp: Breaks with VS2019 installed

Created on 16 May 2019  ·  21Comments  ·  Source: nodejs/node-gyp

node-gyp version 4.0.0
I have vs2015, vs2017 and vs2019 installed, I need them for different projects so uninstalling one isn't really an option.

As far as I can tell, if I use msvs_version=2017, the autodetection now finds the setup for 2019 and then fails to construct the correct path for msbuild which is now at
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
instead of
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe
as node-gyp seems to expect.

Now I'm fine with running the proper 2017 or 2019 and overwriting the msbuild path, doesn't really matter to me, but I can't find how to configure either.
I can apparently overwrite the msbuild path with the command line "--msbuild_path" and thus use vs2019 but the same parameter set globally through "npm config" seems to have no effect.
Any hints?

Multiple node-gyp versions are installed Windows

Most helpful comment

Running this command seems to fix the issue on my system:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"

All 21 comments

Run into the same problem.

Mark.
Me too.
Use "--msbuild_path" successfully & use "npm config" or "--msvs_version" failed.

Running this command seems to fix the issue on my system:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"

Running this command seems to fix the issue on my system:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"

Thank you so much! We've been pulling hair about this for a long time.

运行此命令似乎解决了我的系统上的问题:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe"

No, This won't fix mine.
I can only "--msbuild_path" param at every command, and must be 2017 version.

prefix=D:\Program Files\NodeJS
cache=D:\Program Files\NodeJS\npm_cache
msbuild_path=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe

Set the file "D:\Program Files\NodeJS\node_modules\npm\npmrc" fixed.

Can confirm this setup works

msbuild_path = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
msvs_version = "2017"

(set with npm config)

Using npm config set msvs_version 2019 causes its own problems:

Traceback (most recent call last):
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
    return gyp_main(args)
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
    generator.CalculateVariables(default_variables, params)
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1916, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Users\\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 434, in SelectVisualStudioVersion
    versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2019'

@joaocgreis it seems like https://github.com/nodejs/node-gyp/commit/360ddbdf3a70ae5fc679b8267dfda46969c0d615 should have fixed this is it possible to get a new release cut?

@joaocgreis it seems like 360ddbd should have fixed this is it possible to get a new release cut?

But, some projects cannot be built with 2019.

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


Thanks a million joaocgreis. I am using VS 2019, along with node v10.16.2 and npm V 6.9.0.
Your suggestion resolved gyp build issues with several npm installs, including:
'npm install onoff' and 'npm install serialport'.

npm install --global windows-build-tools

npm install --global windows-build-tools

I believe that will currently install VS 2017 and Python 2.7.17 which might not be desired in this case.

node-gyp has to be the messiest NPM package in existence. I'm trying to write Javascript and suddenly I'm in Microsoft dependency hell. What?

@Pointotech then stop trying to use non-javascript packages that need to be compiled, that's why you're here and Windows is the most difficult platform to be doing this. Clean your dependency tree and keep your catharsis off our issue tracker.

Changing node version to 10.5.0 resolve this problem.
See this

Changing node version to 10.5.0 resolve this problem.
See this

Such a low version. I remember that there is a single 2017 complier installer, that means we need not to install the full 2017 and i have not met again this problem.
I think it is necessary to update python and vs version for Node/NPM.
Many things are out of service.

--And btw, this issue is closed. create or find a newer to metion this issue id.

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
Powershell

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

Finally it worked!!!!
Can't explain the headache I've had for days now <3

Hello !I want to use tfjs-examples,but i have trouble!Please help me...
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.7.6 found at "D:\anaconda\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio installed in "G:\webDownload\straw_hat_fairy-tfjs-examples-master\tfjs-examples\iris-fitDataset\node_modules\deasync\="
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2019 (16.4.29709.97) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - found VC++ toolset: v142
gyp ERR! find VS - found Windows SDK: 10.0.18362.0
gyp ERR! find VS - msvs_version does not point to this installation
gyp ERR! find VS checking VS2017 (15.9.28307.1146) found at:
gyp ERR! find VS "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS - found "Visual Studio C++ core features"
gyp ERR! find VS - found VC++ toolset: v141
gyp ERR! find VS - found Windows SDK: 10.0.17763.0
gyp ERR! find VS - msvs_version does not point to this installation
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS valid versions for msvs_version:
gyp ERR! find VS - "2019"
gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
gyp ERR! find VS - "2017"
gyp ERR! find VS - "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
gyp ERR! find VS
gyp ERR! find VS *******************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS
*******************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (C:\Users\User\AppData\Roaming\npm\node_modulesnode-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modulesnode-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\User\AppData\Roaming\npm\node_modulesnode-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modulesnode-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modulesnode-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modulesnode-gyp\lib\util.js:54:7
gyp ERR! stack at C:\Users\User\AppData\Roaming\npm\node_modulesnode-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:310:5)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1051:16)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\User\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd G:\webDownload\straw_hat_fairy-tfjs-examples-master\tfjs-examples\iris-fitDataset\node_modules\deasync
gyp ERR! node -v v14.2.0
gyp ERR! node-gyp -v v7.0.0

For me the solution was to uninstall node 12.x and install version 10.21 (11.x might also work)

When installing Visual Studio 2017 C++ Build Tools v141 using Visual Studio Installer, I was able to make this build, even when running latest Visual Studio, with no additional configuration required.

image

Was this page helpful?
0 / 5 - 0 ratings