npm install stops with 'No Xcode or CLT version detected' on a Mac
gyp: No Xcode or CLT version detected!Short answer
node-gyp asks xcodebuild for a version and, if that fails, looks for the Command Line Tools package receipt. Neither answered. Install the tools with xcode-select --install, or point xcode-select at a full Xcode.app. Then run npm install again.
Fix it fast
1Find out which cause you have
See which developer directory is active and whether the Command Line Tools package is registered.
xcode-select -p pkgutil --pkg-info com.apple.pkg.CLTools_Executables2Match what you see, then jump to its fix
What does the error look like?
gyp: No Xcode or CLT version detected!gyp ERR! stack Error: `gyp` failed with exit code: 1
Cause 1 of 2
The Command Line Tools are not installed
1Check
node-gyp needs clang, clang++ and make, which the Command Line Tools provide on macOS.
xcode-select -p2Fix
Install the tools on their own with the system installer, then wait for it to finish.
xcode-select --install3Verify
The path prints and the install now builds native modules.
xcode-select -p
npm installConfirmed by raw.githubusercontent.com
Cause 2 of 2
Full Xcode is installed but xcode-select points somewhere else
1Check
The xcode-select tool (see its man page on your Mac) sets the developer directory that xcodebuild and cc use. After an install or move of Xcode it can point at an old path.
xcode-select -p2Fix
Select the Xcode you want (this needs sudo). If you want the default search behaviour back, reset instead.
sudo xcode-select --switch /Applications/Xcode.app
# or
sudo xcode-select --reset3Verify
xcodebuild answers with a version, which is the first thing node-gyp asks.
xcodebuild -versionConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- After a macOS or Xcode upgrade, run xcode-select -p once before your next npm install.
- Prefer package versions that ship prebuilt binaries so no compiler is needed.
- Keep one Xcode or Command Line Tools install active instead of switching often.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
npm install stops while building a native module with node-gyp
Could not find any Python installation to use
node-gyp compiles native add-ons, so it needs a supported Python and a C/C++ compiler.
3 causes, each with a fixBack end
npm install fails because node-gyp cannot find Python
You need to install the latest version of Python.
node-gyp compiles native add-ons and needs a supported Python.
3 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fix