Node-gyp: MSVS 2017 is recognized as 2015

Created on 26 Aug 2017  路  14Comments  路  Source: nodejs/node-gyp

  • Node Version: 8.4.0
  • NPM Version: 5.3.0
  • Platform: Windows 7
  • Compiler: MSVS 2017

I was trying to customize the Platform Toolset variable for a legacy project I'm building when I ran into a strange problem. Essentially I need to set each Visual Studio version to use the _xp variant of the toolset. Everything works except for MSVS 2017, which is recognized as MSVS 2015 (Because it sets it to v140_xp).

"conditions":
[
    [ "MSVS_VERSION == '2012'", { "msbuild_toolset": "v110_xp" }],
    [ "MSVS_VERSION == '2013'", { "msbuild_toolset": "v120_xp" }],
    [ "MSVS_VERSION == '2015'", { "msbuild_toolset": "v140_xp" }],
    [ "MSVS_VERSION == '2017'", { "msbuild_toolset": "v141_xp" }]
]

Doing

npm config set msvs_version 2017

and

node-gyp configure --msvs_version=2017

didn't work so I'm wondering if maybe this is something that isn't supported yet?

Windows

Most helpful comment

I had to choose these under "Individual Components" in the VS2017 installer:

  • Windows 10 SDK (10.0.16299.0) for UWP: C#, VB, JS
  • Windows 10 SDK (10.0.16299.0) for UWP: C++
  • Windows 10 SDK (10.0.16299.0) for Desktop C++ [x86 and x64]
  • Visual Studio C++ core features
  • VC++ 2017 v141 toolset (x86,x64)`

I determined this by, as @joaocgreis said, repeatedly running run node-gyp configure --verbose and checking the output. This was the minimum set of things I had to install on top of my usual C# web development setup.

All 14 comments

What does node-gyp -v print? VS 2017 support was added in v3.6.0.

Hi, it prints out 3.6.2.

@dkrutsko node-gyp is using a compatibility trick to make GYP work since the version that's embeded doesn't have official VS2017 support:
https://github.com/nodejs/node-gyp/blob/7245415296c5f0a97e10dba6dafbaf2332a67578/lib/configure.js#L153-L160

Try patching that, it should work for you.
After we land https://github.com/nodejs/node-gyp/pull/1183 we should remove that kludge.

I have the same problem and can't make it work with 2015 either.

...File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load generator.CalculateVariables(default_variables, params) File "C:\Program Files\nodejs\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:\Program Files\nodejs\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: '2017' gyp ERR! configure error gyp ERR! stack Error:gypfailed with exit code: 1 ...

So how to make node-gyp work with VS2017?

^ answered in #1364- @chen4393 needs to upgrade.

I have the same problem.

node-gyp configure --msvs_version=2017

But it still uses 2015 version, while I have 2017 version installed. So I got an error during node-gyp build:

...\MSVC\14.12.25827\include\variant(16): fatal error C1189: #error:  class template variant is only available w
ith C++17.

BTW node-gyp version is v3.6.2.

node-gyp v3.6.2 still doesn't seem to support VS2017. Taking a quick look at the code: https://github.com/nodejs/node-gyp/blob/master/gyp/pylib/gyp/MSVSVersion.py
There's no reference of 2017, hence the key error someone called out above.

That file isn't used with VS 2017, the logic is here.

Please run node-gyp configure --verbose and check the output for

gyp verb find vs2017 Found installation at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.VC.Tools.x86.x64
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop
gyp verb find vs2017   - Found Microsoft.VisualStudio.VC.MSBuild.Base
gyp verb find vs2017   - Using this installation with Windows 10 SDK
gyp verb find vs2017 using installation: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community

VS2017 needs to have a few components installed to be able to compile C++, otherwise node-gyp will ignore it and try to find a another version with a C++ compiler. The easiest way to get those components is to install the "Desktop development with C++" workload.

I had to choose these under "Individual Components" in the VS2017 installer:

  • Windows 10 SDK (10.0.16299.0) for UWP: C#, VB, JS
  • Windows 10 SDK (10.0.16299.0) for UWP: C++
  • Windows 10 SDK (10.0.16299.0) for Desktop C++ [x86 and x64]
  • Visual Studio C++ core features
  • VC++ 2017 v141 toolset (x86,x64)`

I determined this by, as @joaocgreis said, repeatedly running run node-gyp configure --verbose and checking the output. This was the minimum set of things I had to install on top of my usual C# web development setup.

I don't know what exactly the problem has the originator of the ticket mentioning "_MSVS 2017, which is recognized as MSVS 2015_", but I had a problem that NodeJS scripts call MSBuild which in turn calls build tools from VS 2015, despite I had VS 2017 installed on my machine.

The solution for me was to update my *.vcxproj file and specify there explicitly v141 as a PlatformToolset. And of course, MSBuild.exe must be available in the %PATH% from the VS 2017 directory. If the current ticket is about the same problem, please see my answer here as well: https://stackoverflow.com/a/51132581/4807875.

@dkrutsko Make sure that "msbuild.exe" in your %PATH% targets MSBuild from VS 2017, e.g. C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe. That worked for me.

My guess is that any issues here have probably been resolved with recent releases of node-gyp and the additional Windows work that's gone into it. Please open an new issue if there's something still to be taken care of.

Was this page helpful?
0 / 5 - 0 ratings