This macOS-specific error occurs when node-gyp can't find Xcode Command Line Tools. These tools are required to compile native npm modules on macOS.
The "No Xcode or CLT version detected!" error is macOS-specific. node-gyp needs Xcode Command Line Tools (CLT) to compile native modules because CLT provides: - clang/clang++ (C/C++ compilers) - make - Other build utilities This error commonly occurs: - After macOS system updates (which can invalidate CLT) - On fresh macOS installations - When the xcode-select path is misconfigured - After Xcode was uninstalled or moved You don't need the full Xcode appโjust the Command Line Tools.
Often a simple reset fixes the issue:
sudo xcode-select --resetThen retry npm install.
Install or reinstall CLT:
xcode-select --installA dialog will appear. Click "Install" and wait for completion (may take several minutes).
If CLT is corrupted, do a clean reinstall:
# Check current path
xcode-select --print-path
# Remove existing installation
sudo rm -rf $(xcode-select --print-path)
# Reinstall
xcode-select --installIf you have full Xcode installed, point to it:
# For full Xcode
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
# For CLT only
sudo xcode-select --switch /Library/Developer/CommandLineToolsIf the install command fails, download directly from Apple:
1. Go to https://developer.apple.com/download/all/
2. Sign in with Apple ID
3. Search for "Command Line Tools"
4. Download the version matching your macOS
5. Install the downloaded .dmg file
Confirm CLT is working:
# Check CLT version
xcode-select --version
# Verify compilers work
clang --version
make --version
# Retry npm install
npm cache clean --force
npm installAfter macOS updates: Major macOS updates (Catalina, Big Sur, Monterey, Ventura, Sonoma) often invalidate CLT. Run xcode-select --install after upgrading macOS.
Full Xcode vs CLT: For npm/node-gyp, you only need Command Line Tools (~1GB), not full Xcode (~12GB). However, if you have Xcode installed, ensure xcode-select points to it or CLT.
Known macOS version issues: Some macOS versions had specific CLT bugs:
- Catalina: Required reinstall after certain updates
- Big Sur: Path issues with /Library/Developer
- Monterey/Ventura: Sometimes needs manual download
License agreement: After CLT install, you may need to accept the license:
sudo xcodebuild -license acceptnpm 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