node-gyp cannot find Visual Studio during npm install on Windows
gyp ERR! find VS msvs_version not set from command line or npm configShort answer
On Windows node-gyp needs Visual Studio's C++ build tools to compile a native add-on. The error means it found none it can use. Install the Desktop development with C++ workload, install the VSSetup PowerShell module if detection is blocked, and set msvs_version only for Visual C++ Build Tools 2015.
Fix it fast
1Find out which cause you have
Print the node-gyp version and read the gyp lines above the failing one in the install log; they say which Visual Studio check failed.
node -v npm install --loglevel verbose2Match what you see, then jump to its fix
- 1
The log finds no Visual Studio installation at all.The C++ workload is not installedFix - 2
Visual Studio is installed, yet node-gyp still cannot find it.Detection is blocked by PowerShell's ConstrainedLanguage modeFix - 3
The tools exist but are the 2015 edition.Only the Visual C++ Build Tools 2015 are installedFix
- 1
What does the error look like?
gyp ERR! find VS msvs_version not set from command line or npm configgyp ERR! find VS
Cause 1 of 3
The C++ workload is not installed
1Check
Open the Visual Studio Installer and look for Desktop development with C++ (Visual Studio 2019 or later) or Visual C++ build tools (older versions).
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest2Fix
Install the workload. The node-gyp README also offers a one-command install of Python plus the C++ tools through Chocolatey.
choco install python visualstudio2026-workload-vctools -y3Verify
Open a new terminal and run the install again.
npm installConfirmed by github.com
Cause 2 of 3
Detection is blocked by PowerShell's ConstrainedLanguage mode
1Check
On locked-down machines PowerShell runs in a restricted mode that node-gyp's detection can trip over.
$ExecutionContext.SessionState.LanguageMode2Fix
Install the VSSetup module, which the node-gyp README recommends to avoid this.
Install-Module VSSetup -Scope CurrentUser3Verify
Run npm install again in a new terminal.
npm installConfirmed by github.com
Cause 3 of 3
Only the Visual C++ Build Tools 2015 are installed
1Check
node-gyp cannot auto-detect the 2015 build tools.
node-gyp --version2Fix
Pass the version explicitly when you run node-gyp directly. The README says the flag is not needed when node-gyp runs through npm.
node-gyp configure --msvs_version=20153Verify
The configure step finishes without a find VS error.
node-gyp buildConfirmed by github.com
How do I stop it coming back?
- Document the Visual Studio workload in the project README or setup script.
- Prefer packages that ship prebuilt binaries for your Node.js version.
- Keep one supported Node.js LTS on every developer machine.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
npm install stops while building a native module with node-gyp
Could not find any Python installation to use
node-gyp compiles native add-ons, so it needs a supported Python and a C/C++ compiler.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fixBack end
Angular build says it cannot resolve '@angular/localize/init'
Can't resolve '@angular/localize/init' in '/usr/src/app/src'
The build imports @angular/localize, and that package is not in node_modules.
2 causes, each with a fix