TL;DR
Use the Visual Studio Installer to get the Desktop development with C++ workload in one of the Visual Studio versions you have installed in your machine:
Reason/Details
Reading through the log, the main error is due to this:
msvs_version not set from command line or npm config
After this one you find a few of these:
"Visual Studio C++ core features" missing
And later:
You need to install the latest version of Visual Studio including the "Desktop development with C++" workload.
For more information consult the documentation at:
VS https://github.com/nodejs/node-gyp#on-windows
Finally:
Could not find any Visual Studio installation to use
So to solve the problem, you just need to get "Desktop development with C++" workload.
If you have a Visual Studio version installed
- open Visual Studio Installer (Win + search for it)
- on the list displayed with all Visual Studio Installations you have in your PC, press the Modify button of one of them (preferably the latest version)
- on the Workloads grid/list select the checkbox with Desktop development with C++
- Press one of the Install buttons
gyp will then find that version and use it:
gyp info find Python using Python version 3.8.1 found at "C:UsersUSERAppDataLocalProgramsPythonPython38-32python.exe"
gyp info find VS using VS2019 (16.4.29709.97) found at:
gyp info find VS "C:Program Files (x86)Microsoft Visual Studio2019
With NO Visual Studio installed
Disclaimer: I did not test any of these solutions.
Alternative 1
As Hamid Jolany's answer suggests, on an admin shell, simply install the build tools package globally (node-gyp README):
npm i -g windows-build-tools
Alternative 2
Ragavan's idea/answer for avoiding installing Visual Studio has some logic:
- verify if you have VS build tools by running
npm config get msvs_version
(if you have, skip to step 4 and attempt setting the environment variables)
- if not installed, get the VS build tools latest version exe and install it (Ragavan's idea was with or Microsoft Build Tools 2015)
- run
npm config set msvs_version 2019 --global
(or npm config set msvs_version 2015 --global
according to Ragavan's idea)
- (optional? I have VS installed and do not have this variable declared) set the
VCTargetsPath
environment variable (Win + search for var) to the appropriate path (e.g. C:Program Files (x86)MSBuildMicrosoftPortablev5.0
) or through Run as Admin terminal, as in Ragavan's idea with the 2015 Build Tools:
set VCTargetsPath=C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140
- or in Powershell:
$env:VCTargetsPath=C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V140
Side notes:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…