How to fix npm ERR! No Xcode or CLT version detected! in npm
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.
Quick fix
Fixes npm ERR! No Xcode or CLT version detected!
sudo xcode-select --reset- Reset xcode-select (try first)
- Install Xcode Command Line Tools
- Remove and reinstall CLT
- Set correct xcode-select path
sudo xcode-select --resetnpm ERR! No Xcode or CLT version detected!
What this error means
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.
Typical symptoms
- npm install fails with 'No Xcode or CLT version detected'
- Error occurs only on macOS
- gyp ERR! messages precede this error
- Happens after macOS upgrade
- Native module packages fail to install
Common causes
- Xcode Command Line Tools not installed
- CLT installation corrupted after macOS update
- xcode-select pointing to invalid path
- CLT needs to be reinstalled after OS upgrade
- Multiple Xcode versions causing confusion
How to fix "npm ERR! No Xcode or CLT version detected!"
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 installAdvanced notes
After 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 acceptFrequently asked questions
- What does "npm ERR! No Xcode or CLT version detected!" mean?
- " 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.
- How do I fix "npm ERR! No Xcode or CLT version detected!"?
- 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.
- What causes "npm ERR! No Xcode or CLT version detected!"?
- Xcode Command Line Tools not installed CLT installation corrupted after macOS update xcode-select pointing to invalid path
- Is the "npm ERR! No Xcode or CLT version detected!" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖npm docs: install command(Official Docs)
- 🐙node-gyp GitHub(GitHub)
- 💬SO: npm Xcode(Stack Overflow)