This error occurs when node-gyp tries to compile native Node.js modules on Windows but cannot locate Microsoft Build Tools. It prevents npm install from completing when dependencies require C++ compilation. The fix requires installing Visual Studio Build Tools or properly configuring the MSBuild path.
Node-gyp compiles native C++ modules for Node.js packages. When npm install runs a package with native dependencies, it uses node-gyp to build them. The error means node-gyp searched for MSBuild.exe but could not find it. This typically happens on fresh Windows installs without Visual Studio or Build Tools.
Open PowerShell or Command Prompt as Administrator and run:
npm install --global --production windows-build-toolsThis will download and install Visual Studio Build Tools (~4GB). The installation may take 10-15 minutes.
As an alternative:
1. Download Visual Studio 2022 Community from https://visualstudio.microsoft.com/vs/community/
2. Run the installer
3. Select 'Desktop development with C++' workload (critical)
4. Complete the installation
5. Run npm install again
If you have multiple Visual Studio versions, specify which one:
npm config set msvs_version 2022 --globalReplace 2022 with 2019 or 2017 as needed. Then try npm install again.
If auto-detection fails, specify the full path:
npm config set msbuild_path "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" --globalAdjust the path based on your Visual Studio version.
Older node-gyp versions have detection bugs:
npm install -g node-gyp@latestThen try npm install again.
If the above steps don't work, consider packages that don't require compilation:
- Instead of bcrypt, use bcryptjs
- Instead of node-sass, use sass
- Instead of sqlite3, use better-sqlite3 or sql.js
npm install bcryptjs --saveNode-gyp uses the Windows registry to locate Visual Studio installations. If you manually installed MSBuild without a full Visual Studio installation, the registry entries may be missing. Additionally, Node v14+ works reliably with VS2019/2022, but older versions may require VS2017. The error can also occur when the PATH contains outdated MSBuild entries from old Visual Studio installations.
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