Introduction
After consulting millions of tips online including
- How can I solve error gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config?
- https://github.com/nodejs/node-gyp/issues/1663
- Not looking for VS2013 npm install node modules
- Unable to install npm package (kafka-streams)
and this "comprehensive guide" that introduces ideas that go against the official doc
I still couldn’t install certain third-party packages that require local build over npm or yarn. I’ve also not received any reply from nodejs
or node-gyp
github issue forums.
I’m about to ship an app that already builds well using electron-forge
on macOS, but can’t get it working on Windows.
The main problem is that one of the npm
dependencies for building third-party packages,node-gyp
, couldn’t find Visual Studio on my machine. I use VS2017 Community and have installed all required components for node-gyp
.
My Setup
- Node Version:
node -v
=v12.18.3 andnpm -v
=6.14.8 - Platform:
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type"
(Windows)
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.18362 N/A Build 18362
System Type: x64-based PC
- Compiler:
msbuild /version & cl
(Windows)
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
15.9.21.664Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27043 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
- Module: zeromq
Verbose output (from npm or node-gyp):
me@me-PC0 D:Desktopmyapp
# node-gyp configure --msvs_version=2017
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.8.5 found at "C:PythonPython38python.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 version 2017
gyp ERR! find VS running in VS Command Prompt, installation path is:
gyp ERR! find VS "C:Program Files (x86)Microsoft Visual Studio2017"
gyp ERR! find VS - will only use this version
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - found in "C:Program Files (x86)Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS msvs_version does not match this VS Command Prompt or the
gyp ERR! find VS installation cannot be used.
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:UsersmeAppDataRoamingnpmnode_modulesnode-gyplibfind-visualstudio.js:121:47)
gyp ERR! stack at C:UsersmeAppDataRoamingnpmnode_modulesnode-gyplibfind-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:UsersmeAppDataRoamingnpmnode_modulesnode-gyplibfind-visualstudio.js:351:14)
gyp ERR! stack at C:UsersmeAppDataRoamingnpmnode_modulesnode-gyplibfind-visualstudio.js:70:14
gyp ERR! stack at C:UsersmeAppDataRoamingnpmnode_modulesnode-gyplibfind-visualstudio.js:384:20
gyp ERR! stack at C:UsersmeAppDataRoamingnpmnode_modulesnode-gyplibutil.js:54:7
gyp ERR! stack at C:UsersmeAppDataRoamingnpmnode_modulesnode-gyplibutil.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:1021:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Apps\nodejs\node.exe" "C:\Users\me\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--msvs_version=2017"
gyp ERR! cwd D:Desktopmyapp
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v7.1.0
gyp ERR! not ok
Things I’ve tried to no avail
- Reinstall VS 2017 with
Desktop Development Kit for C++
- Reinstall node and npm
- Run the same command in Admin CMD, Admin PowerShell, Admin VC2017 Dev Command Prompt
- Manually set VCINSTALLDIR environment variable to:
C:Program Files (x86)Microsoft Visual Studio2017Community
- Run
npm config set msvs_version 2017 --global
, thennpm config get msvs_version
gives me 2017 - Restart PC every step of the way
I got the same errors as above every step of the way.
Further attempts
I’ve nuked my entire nodejs installation and started over, but the problem persists. What I’ve done
- Removed nodejs based on this StackOverflow answer.
- Reinstalled nodejs x64 for Windows v12.18.3 using the .msi installer from official nodejs site, allowing the installer to install extra dependencies such as chocolatey
- Created a blank electron app using
electron-forge
: like this
me@me-PC0 D:Desktop
$ npx create-electron-app myapp
√ Initializing Project Directory
√ Initializing Git Repository
√ Locating custom template: "base"
√ Copying Starter Files
√ Initializing NPM Module
√ Installing Template Dependencies
√ Installing NPM Dependencies
me@me-PC0 D:Desktop
$ cd myapp
me@me-PC0 D:Desktopmyapp
$ npm start
> [email protected] start D:Desktopmyapp
> electron-forge start
√ Checking your system
√ Locating Application
√ Preparing native dependencies
√ Launching Application
- Configured VS version that npm uses:
npm config set msvs_version 2017
andnpm config set msvs_version 2017 --global
The app runs up until this point. Then …
- Installed dependency zeromq
$ npm install zeromq --save-prod
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN rm not removing D:Desktopmyappnode_modules.binextract-zip.cmd as it wasn't installed by D:Desktopmyappnode_modulesextract-zip
npm WARN rm not removing D:Desktopmyappnode_modules.binextract-zip as it wasn't installed by D:Desktopmyappnode_modulesextract-zip
npm WARN rm not removing D:Desktopmyappnode_modules.binrimraf.cmd as it wasn't installed by D:Desktopmyappnode_modulesrimraf
npm WARN rm not removing D:Desktopmyappnode_modules.binrimraf as it wasn't installed by D:Desktopmyappnode_modulesrimraf
npm WARN rm not removing D:Desktopmyappnode_modules.binsemver.cmd as it wasn't installed by D:Desktopmyappnode_modulessemver
npm WARN rm not removing D:Desktopmyappnode_modules.binsemver as it wasn't installed by D:Desktopmyappnode_modulessemver
> [email protected] install D:Desktopmyappnode_moduleszeromq
> node-gyp-build
> [email protected] postinstall D:Desktopmyappnode_modulescore-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: electron-installer-debian@^3.0.0 (node_modules@electron-forgemaker-debnode_moduleselectron-installer-debian):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin,linux","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: electron-installer-redhat@^3.2.0 (node_modules@electron-forgemaker-rpmnode_moduleselectron-installer-redhat):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin,linux","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN [email protected] No repository field.
+ [email protected]
added 50 packages from 7 contributors, removed 32 packages, updated 401 packages and audited 460 packages in 61.306s
32 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
- Run electron-forge to build the Windows distribution.
$ npm run make
> [email protected] make D:Desktopmyapp
> electron-forge make
√ Checking your system
√ Resolving Forge Config
We need to package your application before we can make it
√ Preparing to Package Application for arch: x64
× Preparing native dependencies: 0 / 1
An unhandled error has occurred inside Forge:
Command failed with a non-zero return code (1):
D:Desktopmyappnode_moduleselectron-rebuildnode_modules.binnode-gyp.cmd rebuild --target=10.1.0 --arch=x64 --dist-url=https://www.electronjs.org/headers --build-from-source
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 version 2017
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - found in "C:Program Files (x86)Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
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
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 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:121:47)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:351:14)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:70:14
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:384:20
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.js:54:7
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.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:1021:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "D:\Desktop\myapp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=10.1.0" "--arch=x64" "--dist-url=https://www.electronjs.org/headers" "--build-from-source"
gyp ERR! cwd C:UsersmeAppDataLocalTempelectron-packagerwin32-x64myapp-win32-x64resourcesappnode_moduleszeromq
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v7.1.0
gyp ERR! not ok
Error: Command failed with a non-zero return code (1):
D:Desktopmyappnode_moduleselectron-rebuildnode_modules.binnode-gyp.cmd rebuild --target=10.1.0 --arch=x64 --dist-url=https://www.electronjs.org/headers --build-from-source
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 version 2017
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - found in "C:Program Files (x86)Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
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
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 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:121:47)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:351:14)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:70:14
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:384:20
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.js:54:7
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.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:1021:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "D:\Desktop\myapp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=10.1.0" "--arch=x64" "--dist-url=https://www.electronjs.org/headers" "--build-from-source"
gyp ERR! cwd C:UsersmeAppDataLocalTempelectron-packagerwin32-x64myapp-win32-x64resourcesappnode_moduleszeromq
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v7.1.0
gyp ERR! not ok
at ChildProcess.<anonymous> (D:[email protected]:155:16)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at ChildProcess.cp.emit (D:Desktopmyappnode_modulescross-spawnlibenoent.js:34:29)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] make: `electron-forge make`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] make 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:UsersmeAppDataRoamingnpm-cache_logs2020-08-28T04_35_43_345Z-debug.log
- Attempted to fix this by setting
VCINSTALLDIR
environment variable manually
set VCINSTALLDIR=C:Program Files (x86)Microsoft Visual Studio2017Community
- Then run electron-forge again
D:Desktopmyapp>npm run make
> [email protected] make D:Desktopmyapp
> electron-forge make
√ Checking your system
√ Resolving Forge Config
We need to package your application before we can make it
√ Preparing to Package Application for arch: x64
× Preparing native dependencies: 0 / 1
An unhandled error has occurred inside Forge:
Command failed with a non-zero return code (1):
D:Desktopmyappnode_moduleselectron-rebuildnode_modules.binnode-gyp.cmd rebuild --target=10.1.0 --arch=x64 --dist-url=https://www.electronjs.org/headers --build-from-source
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 version 2017
gyp ERR! find VS running in VS Command Prompt, installation path is:
gyp ERR! find VS "C:Program Files (x86)Microsoft Visual Studio2017"
gyp ERR! find VS - will only use this version
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - found in "C:Program Files (x86)Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS msvs_version does not match this VS Command Prompt or the
gyp ERR! find VS installation cannot be used.
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 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:121:47)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:351:14)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:70:14
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:384:20
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.js:54:7
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.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:1021:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "D:\Desktop\myapp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=10.1.0" "--arch=x64" "--dist-url=https://www.electronjs.org/headers" "--build-from-source"
gyp ERR! cwd C:UsersmeAppDataLocalTempelectron-packagerwin32-x64myapp-win32-x64resourcesappnode_moduleszeromq
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v7.1.0
gyp ERR! not ok
Error: Command failed with a non-zero return code (1):
D:Desktopmyappnode_moduleselectron-rebuildnode_modules.binnode-gyp.cmd rebuild --target=10.1.0 --arch=x64 --dist-url=https://www.electronjs.org/headers --build-from-source
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 version 2017
gyp ERR! find VS running in VS Command Prompt, installation path is:
gyp ERR! find VS "C:Program Files (x86)Microsoft Visual Studio2017"
gyp ERR! find VS - will only use this version
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - found in "C:Program Files (x86)Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS msvs_version does not match this VS Command Prompt or the
gyp ERR! find VS installation cannot be used.
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 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:121:47)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:351:14)
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:70:14
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js:384:20
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.js:54:7
gyp ERR! stack at D:Desktopmyappnode_modulesnode-gyplibutil.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:1021:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\Program Files\nodejs\node.exe" "D:\Desktop\myapp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=10.1.0" "--arch=x64" "--dist-url=https://www.electronjs.org/headers" "--build-from-source"
gyp ERR! cwd C:UsersmeAppDataLocalTempelectron-packagerwin32-x64myapp-win32-x64resourcesappnode_moduleszeromq
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v7.1.0
gyp ERR! not ok
at ChildProcess.<anonymous> (D:[email protected]:155:16)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at ChildProcess.cp.emit (D:Desktopmyappnode_modulescross-spawnlibenoent.js:34:29)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] make: `electron-forge make`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] make 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:UsersmeAppDataRoamingnpm-cache_logs2020-08-28T04_40_16_364Z-debug.log
- Also tried to hack the visual studio locator code of node-gyp at
D:Desktopmyappnode_modulesnode-gyplibfind-visualstudio.js
to insertamd64
to the lines
if (versionYear === 2017) {
return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe')
}
if (versionYear === 2019) {
return path.join(info.path, 'MSBuild', 'Current', 'Bin', 'MSBuild.exe')
}
so that they become
if (versionYear === 2017) {
return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'amd64', 'MSBuild.exe')
}
if (versionYear === 2019) {
return path.join(info.path, 'MSBuild', 'Current', 'Bin', 'amd64', 'MSBuild.exe')
}
- Then run
npm run make
again. Same errors as previous step.
Here is my build environment
D:Desktopmyapp>npm config get msvs_version
2017
D:Desktopmyapp>npm config get python
C:PythonPython38pythonw.exe
Python 3.8 is the 64bit version from python.org.
Question
What am I missing? Should I forget about VS2017? My project uses VS2017 for the C++ development so I’m afraid I can’t change that. But should I install VS2015?
It’s confusing that on node-gyp README.md
, it first says
Launch cmd,
npm config set msvs_version 2017
Then later in How to Use
, it then says:
Auto-detection fails for Visual C++ Build Tools 2015, so --msvs_version=2015 needs to be added (not needed when run by npm as configured above):
$ node-gyp configure --msvs_version=2015
What’s with this version discrepancy?
2
Answers
Finally figured it out myself.
Culprit
The Visual Studio environment variable
LIB
was contaminated on my local machine. There are some illegal characters in some paths in there, causingnode-gyp
parsing issues. After those characters are fixed, the problem went away.Also, the 64bit fix in
node-gyp
source that I mentioned in the question is necessary:How did I find it
I really had to go into
node-gyp
source code to locate the issue. The way it locates Visual Studio installation is through a PowerShell command which calls another C# scriptFind-VisualStudio.cs
that does the OS query job.Unfortunately, the error log of this PowerShell command is not reflected in the immediate
node-gyp
ornpm
logs. After I yanked the command out and ran it in PowerShell, voila! The underlying system log from the PowerShell command run says something wrong with myLIB
variable.Moral lessons
Try using the
windows-build-tools
npm package: https://www.npmjs.com/package/windows-build-tools. It’s a package specifically designed to set up an environment for native builds like this on Windows.You just need to install it globally:
That’s not guaranteed to work, given all your existing configuration, but on a clean system that alone should be sufficient to get a working build environment. If you still have trouble, their Github issue tracker & README (https://github.com/felixrieseberg/windows-build-tools) has quite a few suggestions. Good luck!