Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVS 2017 is recognized as 2015 #1278

Closed
dkrutsko opened this issue Aug 26, 2017 · 14 comments
Closed

MSVS 2017 is recognized as 2015 #1278

dkrutsko opened this issue Aug 26, 2017 · 14 comments
Assignees
Labels

Comments

@dkrutsko
Copy link

  • 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?

@bnoordhuis
Copy link
Member

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

@refack refack self-assigned this Aug 29, 2017
@dkrutsko
Copy link
Author

Hi, it prints out 3.6.2.

@refack
Copy link
Contributor

refack commented Aug 29, 2017

@dkrutsko node-gyp is using a compatibility trick to make GYP work since the version that's embeded doesn't have official VS2017 support:

node-gyp/lib/configure.js

Lines 153 to 160 in 7245415

// GYP doesn't (yet) have support for VS2017, so we force it to VS2015
// to avoid pulling a floating patch that has not landed upstream.
// Ref: https://chromium-review.googlesource.com/#/c/433540/
gyp.opts.msvs_version = '2015'
process.env['GYP_MSVS_VERSION'] = 2015
process.env['GYP_MSVS_OVERRIDE_PATH'] = vsSetup.path
defaults['msbuild_toolset'] = 'v141'
defaults['msvs_windows_target_platform_version'] = vsSetup.sdk

Try patching that, it should work for you.
After we land #1183 we should remove that kludge.

@ekelvin
Copy link

ekelvin commented Dec 7, 2017

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:gyp failed with exit code: 1 ...

@chen4393
Copy link

So how to make node-gyp work with VS2017?

@bnoordhuis
Copy link
Member

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

@jsmonkey
Copy link

jsmonkey commented Feb 7, 2018

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.

@swingtempo
Copy link

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.

@bnoordhuis
Copy link
Member

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

@joaocgreis
Copy link
Member

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.

@zpbd
Copy link

zpbd commented May 22, 2018

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.

@AlexanderSamoilov
Copy link

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.

@vtkachenko
Copy link

@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.

@rvagg
Copy link
Member

rvagg commented Jun 20, 2019

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.

@rvagg rvagg closed this as completed Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests