npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
4 min

banner

# npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio

To solve the "npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio" error:

  1. Install the latest version of Visual Studio including the "Desktop development with C++" workload.
  2. Update your npm version to the latest.
  3. Delete your node_modules and package-lock.json files and rerun npm install.

npm err gyp err find vs you need to install the latest version

Here is the stack trace from the error.

shell
npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! Visual Studio C++ core features missing npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! For more information consult the documentation at: https://github.com/nodejs/node-gyp#on-windows npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! not ok
  1. Download the Visual Studio installer.

download visual studio

  1. Start the installer and click on "Continue".

start visual studio intaller

  1. Make sure to tick the "Desktop development with C++" option and click on "Install".

install microsoft build tools

  1. Wait for the installation to complete.

wait for the installation to complete

As the error message states:

  • You need to install the latest version of Visual Studio including the "Desktop development with C++" workload.

If you already have Visual Studio installed:

  1. Click on the Search bar and type "Visual Studio Installer".

search-for-visual-studio-installer

  1. Click on "Modify".

  2. Tick the "Desktop development with C++" option and click on "Modify".

You might have to restart your PC after installing Visual Studio.

If the error persists, try to delete your node_modules and package-lock.json files.

# Delete your node_modules and package-lock.json files

If the error is not resolved, try to delete your node_modules and package-lock.json (not package.json) files, re-run npm install and restart your IDE.

cmd
# ๐Ÿ‘‡๏ธ (Windows) delete node_modules and package-lock.json rd /s /q "node_modules" del package-lock.json # ๐Ÿ‘‡๏ธ (macOS/Linux) delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json # ๐Ÿ‘‡๏ธ clean your npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

Make sure to restart your IDE and shell if the error persists. Visual Studio Code often glitches and a reboot solves things sometimes.

If the error persists, try to update your npm and Node.js versions or use nvm to manage your Node.js version.

# Try to update your npm and Node.js versions or use nvm

First, update your NPM version by running the following command.

shell
npm install -g npm@latest # ๐Ÿ‘‡๏ธ If you get a permissions error on macOS / Linux sudo npm install -g npm@latest

If you get a permissions error on Windows, open CMD as an administrator and rerun the command.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Rerun the command.
shell
npm install -g npm@latest npm install -g npm@latest --force

If that didn't help, try to download and install the long-term supported version of Node.js.

To install Node:

  1. Open the nodejs.org page and download the Windows installer for the LTS (long-term supported) version.

download node lts version

  1. Start the installer and click Next on the Welcome screen.

node start installer

  1. Accept the end-user license agreement and click Next.

node accept end user agreement

  1. Leave the default destination folder selected and click Next.

node select destination folder

  1. On the "Custom Setup" screen, click Next.

node custom setup

  1. You can optionally install tools for native modules, otherwise, click Next.

node tools for native modules

  1. On the next screen, click on the Install button.

node click install

  1. Lastly, click on the Finish button.

node click finish

  1. Make sure to close any existing command prompts and PowerShell instances for the PATH variable to get updated.

  2. You can start a new CMD shell and use the npm --version command to make sure Node is installed.

cmd
npm --version node --version npm install -g npm@latest

get node npm version

If the error is not resolved, try to restart your PC after installing the LTS version of Node.

# Use nvm if you need to manage multiple Node.js versions

If you need to manage multiple Node.js versions, you can use the nvm package.

There are 2 nvm packages:

I have written detailed, step-by-step guides on how to install NVM on Windows and macOS or Linux:

Make sure to follow the step-by-step instructions. Once you switch to the long-term supported Node.js version, the error will be resolved.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev