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

[windows] node-gyp fails to find Visual Studio Build Tools 2017 #2002

Closed
Zireael opened this issue Dec 22, 2019 · 19 comments
Closed

[windows] node-gyp fails to find Visual Studio Build Tools 2017 #2002

Zireael opened this issue Dec 22, 2019 · 19 comments
Labels
ERR! node-gyp -v < v10.x.x npm install -g npm Node Sass --> Dart Sass https://github.com/sass/node-sass/issues/2952

Comments

@Zireael
Copy link

Zireael commented Dec 22, 2019

Hi,
node-gyp fails to find Visual Studio Build Tools 2017

msvs_version does not match this version
could not find a version of Visual Studio 2017 or newer to use

  • node-gyp version: node-gyp v5.0.7
  • Node Version: node v13.1.0 npm 6.12.1
  • Platform: Windows 10
  • Compiler: 15.9.21.664 (Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework)
  • Module: ffs
Verbose output (from npm or node-gyp):
V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor>node-gyp rebuild --verbose
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'X:\\Program Files\\Node\\node.exe',
gyp verb cli   'C:\\Users\\OSO\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose'
gyp verb cli ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path
gyp verb find Python - executable path is "X:\Program Files\Python\Python3\python.exe"
gyp verb find Python - executing "X:\Program Files\Python\Python3\python.exe" to get version
gyp verb find Python - version is "3.8.0"
gyp info find Python using Python version 3.8.0 found at "X:\Program Files\Python\Python3\python.exe"
gyp verb get node dir no --target version specified, falling back to host node version: 13.1.0
gyp verb command install [ '13.1.0' ]
gyp verb install input version string "13.1.0"
gyp verb install installing version: 13.1.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 13.1.0
gyp verb build dir attempting to create "build" dir: V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\build
gyp verb build dir "build" dir needed to be created? V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\build
gyp verb find VS msvs_version not set from command line or npm config
gyp verb find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp verb find VS checking VS2017 (15.9.28307.960) found at:
gyp verb find VS "X:\Program Files\Visual Studio\Build Tools 2017"
gyp verb find VS - found "Visual Studio C++ core features"
gyp verb find VS - found VC++ toolset: v141
gyp verb find VS - found Windows SDK: 10.0.17763.0
gyp info find VS using VS2017 (15.9.28307.960) found at:
gyp info find VS "X:\Program Files\Visual Studio\Build Tools 2017"
gyp info find VS run with --verbose for detailed information
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\build\config.gypi
gyp verb config.gypi checking for gypi file: V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\config.gypi
gyp verb common.gypi checking for gypi file: V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn X:\Program Files\Python\Python3\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\OSO\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-I',
gyp info spawn args   'V:\\Programming\\JavaScript\\Programming\\Projects\\_node\\node-tablet-monitor\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\OSO\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\OSO\\AppData\\Local\\node-gyp\\Cache\\13.1.0\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\OSO\\AppData\\Local\\node-gyp\\Cache\\13.1.0',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\OSO\\AppData\\Roaming\\npm\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\\\Users\\\\OSO\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\13.1.0\\\\<(target_arch)\\\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=V:\\Programming\\JavaScript\\Programming\\Projects\\_node\\node-tablet-monitor',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'V:\\Programming\\JavaScript\\Programming\\Projects\\_node\\node-tablet-monitor\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp: binding.gyp not found (cwd: V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Users\OSO\AppData\Roaming\npm\node_modules\node-gyp\lib\configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "X:\\Program Files\\Node\\node.exe" "C:\\Users\\OSO\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose"
gyp ERR! cwd V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.7
gyp ERR! not ok
V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor>npm install -g node-gyp
C:\Users\OSO\AppData\Roaming\npm\node-gyp -> C:\Users\OSO\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js
+ [email protected]
updated 1 package in 2.258s

V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor>npm install ffi

> [email protected] install V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\node_modules\ref
> node-gyp rebuild


V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\node_modules\ref>if not defined npm_config_node_gyp (node "X:\Program Files\Node\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
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 2015
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2017 (15.9.28307.960) found at:
gyp ERR! find VS "X:\Program Files\Visual Studio\Build Tools 2017"
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 match this version
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 - "2017"
gyp ERR! find VS - "X:\Program Files\Visual Studio\Build Tools 2017"
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 (X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack     at X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at X:\Program Files\Node\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:302:5)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at maybeClose (internal/child_process.js:1028:16)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "X:\\Program Files\\Node\\node.exe" "X:\\Program Files\\Node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd V:\Programming\JavaScript\Programming\Projects\_node\node-tablet-monitor\node_modules\ref
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install 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:\Users\OSO\AppData\Roaming\npm-cache\_logs\2019-12-22T13_55_29_502Z-debug.log
@mohamad-alibrahim
Copy link

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 **************************************************************

@Zireael
Copy link
Author

Zireael commented Jan 20, 2020

The problem is, I have installed build tools both ways as described in https://github.com/nodejs/node-gyp#on-windows, have Python installed. Added both build tools and Python to Path and npm config variables.

For example:
image

Still getting the same error message. :/

@STDSuperman
Copy link

So,how did you solve it in the end.

@codycuellar
Copy link

We are having this exact same problem on automated test machines in production. Out of nowhere all of our Windows machines are slowly failing to install/compile anything with node-gyp. I've tried re-installing windows-build-tools, both 5.2.2 and the latest v4. We're on Windows 10, NPM 6.13.4, and node 10.18.1.

@intrueder
Copy link

Check if changing line 270 in node_modules\node-gyp\lib\find-visualstudio.js
from

return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'MSBuild.exe')

to

return path.join(info.path, 'MSBuild', '15.0', 'Bin', 'amd64', 'MSBuild.exe')

will help you.

@dsteinman
Copy link

dsteinman commented Mar 11, 2020

I have this exact same problem. I am completely stuck. I've installed Python manually.

I've run npm install --global --production windows-build-tools. I've manually installed both the 2019 and 2017 version of Visual Studio Community. Same problem. This is a fresh Windows 10 install, anyone with Windows 10 will probably encounter this problem.

@nhustak
Copy link

nhustak commented Mar 19, 2020

I too am having this problem. It appears to not be finding the 2015 or 2017 tools I have installed. The culprit here is node-sass which is set to node-gyp 3.8

gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir C:\Users\nhust\.node-gyp\12.13.1
gyp verb found first Solution file build/binding.sln
gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\15.0\Bin\MSBuild.exe ENOENT
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
gyp ERR! stack     at onErrorNT (internal/child_process.js:456:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\ProjAngular\\SupervisionServices\\node_modules\\devextreme-cli\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\ProjAngular\SupervisionServices\node_modules\devextreme-cli\node_modules\node-sass
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! This is a bug in `node-gyp`.

@cclauss
Copy link
Contributor

cclauss commented Mar 19, 2020

Please try the solution that worked at #2069 (comment)

@nhustak
Copy link

nhustak commented Mar 19, 2020

@cclauss Thank you for the reply. I have removed and reinstalled the node_modules directory multiple times this morning - been fighting this for hours. node-gyp is at 6.1 in the node_modules directory. However, the node-sass compile is somehow still getting v3.8.0. I just removed the directory, verified what version of node-gyp was in the package.json and it is 6.1. Verified what installed. I still have the exact same error as above.

@richardlau
Copy link
Member

node-sass has pinned itself to an old version of node-gyp: https://github.com/sass/node-sass/blob/b54053a1b50fd97e951eb0311a7fb818683a8e99/package.json#L67
Apparently they won't update until their next semver-major: sass/node-sass#2716

@nhustak
Copy link

nhustak commented Mar 19, 2020

@richardlau That's what I thought I was seeing. Thank you. I'm still a newbie at reviewing the package.json files. Ok so it sounds like I am on the wrong tree here as far as getting this to work. I need to figure out how to get node-gyp to look at VS2017 or VS2015. Thanks for the assist.

@nhustak
Copy link

nhustak commented Mar 19, 2020

Unfortunately neither of these seems to fix the problem. It's still reaching out to 2019 to do the compile.
npm config set msvs_version 2017 and yarn config set msvs_version 2017

@intrueder
Copy link

Hey @nhustak ,
this line

gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\15.0\Bin\MSBuild.exe

says it will try to execute 32-bit binary.

But the args

gyp info spawn args   '/p:Configuration=Release;Platform=x64'

say that target is x64.

What you need is to make it execute 64-bit binary, which is located under "amd64" subfolder.

Please, read the comment above #2002 (comment) . It works for me (drawback is that it is a local change)

@nhustak
Copy link

nhustak commented Mar 19, 2020

@intrueder Well thank you very very much. That worked!

@codycuellar
Copy link

codycuellar commented Mar 22, 2020

WARNING: THIS MAY NOT BE SAFE FOR ALL USE CASES
If changing your security policies is acceptable - I found that the setting User Account Control: Admin Approval Mode for the Build-in Administrator Account policy in secpol:: Local Policies > Security Options had to be disabled explicitly and the problem went away. I was able to trace the core issue (for me) to an issue with the PowerShell script in node-gyp that searches the registry for a VS installation which wouldn't run due to a security restriction that disabling this policy lifted.

https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-account-control-admin-approval-mode-for-the-built-in-administrator-account

@bnoordhuis
Copy link
Member

I'm going to close this. It's been inactive for over a month and it doesn't really seem to be an issue with (a recent version of) node-gyp.

@cclauss cclauss added ERR! node-gyp -v < v10.x.x npm install -g npm Node Sass --> Dart Sass https://github.com/sass/node-sass/issues/2952 labels Jul 3, 2020
@lukeapage
Copy link

I was having a similar problem to this where Find-VisualStudio.cs was returning nothing from the execFile.

After much debugging it turned out I was spawning the yarn command (which in turn spawned node-gyp) and I had specified env which meant that the system default environment variables were not passed through. By adding ...process.env onto my spawn on yarn - node-gyp was able to find visual studio again.

@gthorvey
Copy link

gthorvey commented Jul 1, 2021

I have latest Windows 10. tried with node_gyp version 8.1.. I tried with both Visual Studion 2017 and 2019 . Still not able to proceed

@cclauss
Copy link
Contributor

cclauss commented Jul 1, 2021

No log makes it a guessing game.

@nodejs nodejs locked as off-topic and limited conversation to collaborators Jul 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ERR! node-gyp -v < v10.x.x npm install -g npm Node Sass --> Dart Sass https://github.com/sass/node-sass/issues/2952
Projects
None yet
Development

No branches or pull requests