Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

node-gyp cannot find Visual Studio during npm install on Windows

Errorgyp ERR! find VS msvs_version not set from command line or npm config

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

  • Applies to Windows 11, Node.js 22, Visual Studio 2022
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 verbose
  2. 2Match what you see, then jump to its fix

    1. 1The log finds no Visual Studio installation at all.The C++ workload is not installedFix
    2. 2Visual Studio is installed, yet node-gyp still cannot find it.Detection is blocked by PowerShell's ConstrainedLanguage modeFix
    3. 3The tools exist but are the 2015 edition.Only the Visual C++ Build Tools 2015 are installedFix

What does the error look like?

  • gyp ERR! find VS msvs_version not set from command line or npm config
  • gyp 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" -latest

2Fix

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

3Verify

Open a new terminal and run the install again.

npm install

Confirmed by github.com

Did this fix it?

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

2Fix

Install the VSSetup module, which the node-gyp README recommends to avoid this.

Install-Module VSSetup -Scope CurrentUser

3Verify

Run npm install again in a new terminal.

npm install

Confirmed by github.com

Did this fix it?

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

2Fix

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=2015

3Verify

The configure step finishes without a find VS error.

node-gyp build

Confirmed by github.com

Did this fix it?

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

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 fix

Back 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.