Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-gyp error Could not find any Visual Studio installation to use

The problem that I am having is that I cant install the packages for a project, it keeps erroring with:

npm ERR! npm ERR! gyp ERR! find VS valid versions for msvs_version:
npm ERR! npm ERR! gyp ERR! find VS
npm ERR! npm ERR! gyp ERR! find VS **************************************************************
npm ERR! npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio
npm ERR! npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload.
npm ERR! npm ERR! gyp ERR! find VS For more information consult the documentation at:
npm ERR! npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
npm ERR! npm ERR! gyp ERR! find VS **************************************************************

I have tried to follow advice from these threads that other people had:

How to fix node.js error like "gyp ERR! find VS including the "Desktop development with C++" workload." when I launch Nuxt.js project

And this How can I solve error gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config?

But neither seemed to help.

What I have done so far:

  • I installed the latest VS Code (2022 Community) with Desktop development with C++ along with MSVC v143 - VS 2022 C++ x64/x86 build tools

  • I have configured msvs_version to have the value of 2022, I did that with npm config set msvs_version=2022 and with node-gyp configure --msvs_version=2022

  • I have tried installing windows build tools npm install --global --production windows-build-tools but it just says that ...Node.js now incldues build tools for Windows...

  • I have also manually built the node-gyp using the commands found in the second post I listed above node-gyp configure node-gyp configure --msvs_version=2022 node-gyp build and its all greens and oks

And I have no idea what else I can do

like image 510
Darkbound Avatar asked Dec 04 '25 15:12

Darkbound


2 Answers

Solved node-gyp in Windows 11, VSCode, Visual Studio 2022

node -v
v18.4.0

nvm version
1.1.9

node-gyp -v
v9.0.0



node-gyp configure --msvs_version=2022

enter image description here

Start Visual Studio Installer

enter image description here

Beside Visual Studio Community 2022 -> Modify ->Individual Components Type Visual C++

enter image description here

Make sure MSVC v143 ... x64/x86 build tools (Latest) is checked.

Check current Windows version

enter image description here

enter image description here

Back to Visual Studio install, type SDK, and find the correct SDK version. for me, Windows 11 SDK (10.0.22000.0)

enter image description here

After all those setup.. I still get

gyp ERR!  find VS - does not match this Visual Studio Command Prompt

knowing that I have to hack the code

adding this 3 lines above the error log

    +this.addLog("this.envVcInstallDir: " + this.envVcInstallDir)
    +this.addLog("vsPath: " + vsPath)
    +this.addLog("path.relative(this.envVcInstallDir, vsPath): " + path.relative(this.envVcInstallDir, vsPath))
    if (this.envVcInstallDir &&
      path.relative(this.envVcInstallDir, vsPath) !== '') {
      this.addLog('- does not match this Visual Studio Command Prompt')
      return false
    }

and tracing into

    if (process.env.VCINSTALLDIR) {
      this.envVcInstallDir =
        path.resolve(process.env.VCINSTALLDIR, '..')
      this.addLog('running in VS Command Prompt, installation path is:\n' +
        `"${this.envVcInstallDir}"\n- will only use this version`)
    } else {
      this.addLog('VCINSTALLDIR not set, not running in VS Command Prompt')
    }

enter image description here

Finally, have to add something at the end of VCINSTALLDIR

Problem solved, will uninstall VS 2017 & 2019 to save space.

like image 77
Eric Avatar answered Dec 06 '25 17:12

Eric


I found the problem after hours of searching, it was my node version, i was at 16.x.x, I installed node version manager and moved to version 14 and it worked.

like image 29
Darkbound Avatar answered Dec 06 '25 17:12

Darkbound



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!