I’m encountering an error every time I run the npm install command to add new packages. The message says gyp: No Xcode or CLT version detected!.
This problem started right after I updated to the latest macOS version. My Node.js version is v8.8.0 and npm is v6.11.3. It happens on both the terminal in my code editor and the regular terminal application.
Below is the output of the error I get:
> [email protected] install /Users/developer/Projects/my-app/node_modules/file-watcher/node_modules/events-fs
> node-gyp rebuild
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/Users/developer/.nvm/versions/node/v8.8.0/bin/node" "/Users/developer/.nvm/versions/node/v8.8.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! node -v v8.8.0
gyp ERR! node-gyp -v v5.0.3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected]
Yeah, this is a classic Command Line Tools issue that happens after macOS updates. I hit the same problem a few months ago and just reinstalling CLT wasn’t enough. After running xcode-select --install, I had to manually accept the license with sudo xcodebuild -license accept. Sometimes the system doesn’t register the CLT installation without this step. Check if everything’s working with xcode-select -p - it should return /Library/Developer/CommandLineTools. If you get something else or an error, that’s your problem right there. Also, your Node.js v8.8.0 is pretty old and might not play nice with newer macOS versions. I’d update to a recent LTS version once you fix this.
Had the exact same issue after my macOS update. What happens is the update breaks Command Line Tools that node-gyp needs to compile native modules. Even if you had CLT installed before, the update can mess it up. Here’s what fixed it for me: completely nuke and reinstall Command Line Tools. Run sudo rm -rf /Library/Developer/CommandLineTools to remove the broken installation, then xcode-select --install for a fresh copy. Once that’s done, try your npm install again. Still having problems? Reset the xcode-select path with sudo xcode-select --reset. This fixed the detection issue and got node-gyp working again.
macOS updates always break this stuff… try sudo xcode-select --install first, but if that doesn’t work you might need to clear the cache too. Run npm cache clean --force and maybe rm -rf node_modules && npm install after fixing the CLT issue. Worked for me with similar problems.