Skip to content

node-gyp fails to detect Visual Studio 2026 (version 18.x) #3282

Description

@grahas

node-gyp fails to detect Visual Studio 2026 (version 18.x)

Description

node-gyp is unable to detect and use Visual Studio 2026 (internal version 18.x), reporting it as "unknown version 'undefined'" when attempting to build native modules. This prevents npm packages with native dependencies from being installed.

Environment

System Information:

  • OS: Windows NT 10.0.26200.0
  • Node.js: v24.11.1
  • npm: 11.6.2
  • node-gyp: v11.4.2 (bundled with npm)
  • Python: 3.14.2

Visual Studio Installation:

  • Version: Visual Studio 2026 Community
  • Internal Version: 18.2.11415.280
  • Installation Path: C:\Program Files\Microsoft Visual Studio\18\Community
  • VCINSTALLDIR: C:\Program Files\Microsoft Visual Studio\18\Community\VC\
  • Workloads: Desktop development with C++ (confirmed installed)

Additional VS Installations:

  • Visual Studio 2019 Community (16.11.36631.11) at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community (missing VC++ toolset)

Steps to Reproduce

  1. Install Visual Studio 2026 with "Desktop development with C++" workload
  2. Set environment variable VCINSTALLDIR to point to VS2026 installation
  3. Attempt to install any npm package that requires native compilation:
    npm install @vscode/windows-mutex

Expected Behavior

node-gyp should detect Visual Studio 2026 and use it to build native modules successfully.

Actual Behavior

node-gyp fails with the following error:

gyp ERR! find VS 
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS running in VS Command Prompt, installation path is:
gyp ERR! find VS "C:\Program Files\Microsoft Visual Studio\18\Community"
gyp ERR! find VS - will only use this version
gyp ERR! find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\18\Community"
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details.

Full error output:

gyp ERR! find VS Failure details: undefined
gyp ERR! find VS unknown version "undefined" found at "C:\Program Files\Microsoft Visual Studio\18\Community"
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\[user]\AppData\Local\nvm\v24.11.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:118:11)
gyp ERR! stack     at VisualStudioFinder.findVisualStudio (C:\Users\[user]\AppData\Local\nvm\v24.11.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:17)

Root Cause Analysis

The issue appears to be in find-visualstudio.js where node-gyp:

  1. Detects the VS2026 installation at the correct path
  2. Recognizes that it's running in a VS Command Prompt (VCINSTALLDIR is set)
  3. Attempts to determine the version but gets undefined
  4. Rejects the installation because the version is unknown

The version detection logic appears to only recognize Visual Studio versions up to 2022 (version 17.x) and does not handle version 18.x (VS2026).

Workarounds Attempted

  1. Setting msvs_version manually:

    npm install --msvs_version=2022

    Result: Still fails, as node-gyp rejects the VS2026 installation when running in VS Command Prompt

  2. Clearing VCINSTALLDIR environment variable:

    $env:VCINSTALLDIR = $null
    npm install

    Result: Same error - PowerShell detection also fails to recognize VS2026

  3. Using --ignore-scripts flag:

    npm install --ignore-scripts

    Result: Works, but native modules are not built and cause runtime errors

Proposed Solution

Update lib/find-visualstudio.js to:

  1. Recognize Visual Studio version 18.x as Visual Studio 2026
  2. Add version 18 to the list of supported Visual Studio versions
  3. Update version detection regex/logic to handle the new version format

Impact

This affects all users who:

  • Have upgraded to Visual Studio 2026
  • Are using Node.js v22+ (which requires VS2017 or newer)
  • Need to install npm packages with native dependencies

Additional Context

Visual Studio 2026 was released as a preview/early access version with major version number 18.x. As adoption increases, this will become a blocking issue for the Node.js ecosystem.

Related Files

The issue likely needs changes in:

  • lib/find-visualstudio.js - Version detection logic
  • Documentation to list VS2026 as supported

Request

Please add support for Visual Studio 2026 (version 18.x) to node-gyp's Visual Studio detection mechanism.


Package: node-gyp
Version: 11.4.2
Platform: Windows
Node Version: 24.11.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions