This error occurs when node-gyp cannot locate a valid Visual Studio installation needed to compile native Node.js modules on Windows. You need the C++ build tools from Visual Studio, which can be installed or configured through several methods.
node-gyp is a tool that compiles native C++ modules for Node.js packages. When you install a package containing native code, npm automatically runs node-gyp. On Windows, node-gyp needs Visual Studio's C++ compiler and build tools. This error means node-gyp couldn't find a valid installation.
Download Visual Studio Community from https://visualstudio.microsoft.com/downloads/
If installing fresh:
1. Run the installer
2. Select 'Desktop development with C++' (this is critical)
3. Click 'Install' and wait for completion
4. Restart your computer
If already have Visual Studio:
1. Open 'Visual Studio Installer'
2. Click 'Modify'
3. Check 'Desktop development with C++'
4. Click 'Modify' to apply
Tell npm which version to use:
# For Visual Studio 2022
npm config set msvs_version=2022 --global
# For Visual Studio 2019
npm config set msvs_version=2019 --globalThen retry npm install.
If using Node.js older than v16, node-gyp may not recognize modern Visual Studio versions.
Download Node.js v18 LTS or later from https://nodejs.org
If you don't want the full Visual Studio IDE:
# Run as Administrator in PowerShell
npm install --global --production windows-build-toolsOr via Chocolatey:
choco install python visualstudio2022-workload-vctools -yEnsure your Node.js architecture (x64 vs ARM64) matches your system. Check with node -p "process.arch". WSL2 users: npm install may fail in Windows Subsystem for Linux if Visual Studio is only installed on the Windows host. Consider installing build-essential in WSL instead: sudo apt-get install build-essential python3.
npm ERR! code E401 npm ERR! 401 Unauthorized - Token has expired
Token has expired - npm authentication failure
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm ERR! code EWORKSPACEMISSING npm ERR! Workspace does not exist: packages/missing
How to fix "npm ERR! code EWORKSPACEMISSING - Workspace does not exist" error
npm ERR! code EADDRNOTAVAIL npm ERR! errno EADDRNOTAVAIL npm ERR! Address not available
How to fix "npm ERR! code EADDRNOTAVAIL - Address not available" error