This error occurs when npm tries to build native modules during package installation but cannot find or access Xcode Command Line Tools on macOS. Node-gyp requires Xcode CLT to compile C/C++ dependencies.
When you run `npm install`, some packages contain native C/C++ code that must be compiled. Node-gyp handles this compilation. The error means node-gyp tried to query the Xcode developer directory path but failed. This typically happens because Xcode Command Line Tools are not installed, the developer directory path is misconfigured, or a macOS update invalidated the previous installation.
First, verify what path xcode-select is using:
xcode-select --print-pathIf this returns an error or empty string, CLT is missing.
The simplest solution is resetting xcode-select:
sudo xcode-select --resetVerify it worked:
xcode-select --print-pathShould show /Applications/Xcode.app/Contents/Developer or /Library/Developer/CommandLineTools. Now try npm install again.
If reset didn't work, reinstall CLT:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --installA popup window will appear. Click 'Install' and wait for completion (10-20 minutes).
If you have full Xcode.app installed, point xcode-select to it:
sudo xcode-select --switch /Applications/Xcode.app/Contents/DeveloperVerify:
xcode-select --print-pathIf automatic installer fails:
1. Visit https://developer.apple.com/download/all/
2. Sign in with your Apple ID
3. Search for 'Command Line Tools'
4. Download the .dmg matching your macOS version
5. Open the .dmg and run the installer
6. Verify with xcode-select --print-path
7. Retry npm install
If using Python 3.12+, you need node-gyp 10+:
npm install -g node-gyp@latest
npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"Retry npm install.
The xcode-select tool manages the developer directory path used by build tools. After macOS updates (especially major version upgrades), the developer directory path can become stale, requiring reset or reinstall. Most cases can be resolved with sudo xcode-select --reset; full Xcode installation is rarely necessary unless you develop for iOS. If you're in an organization with security software, xcode-select --install may failβin that case, manual download is required.
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