Error with node-gyp configuration: 'gyp: No Xcode or CLT version detected!' during npm install

Whenever I attempt to install packages using npm, I encounter an error that halts the process completely. The error message appears consistently with the following detail:

gyp: No Xcode or CLT version detected!

Currently, I’m using node -v → v8.8.0 and npm -v → v6.11.3.

I’ve tried executing this command in both the VSCode terminal and iTerm, and both yield the same results. This problem arose after I updated my macOS to Catalina 10.15.3. Below is the detailed error log that I receive:

$ npm install

> [email protected] install /Users/synapse/Documents/synapsefi-dev-ui/node_modules/watchpack/node_modules/fsevents
> 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! stack     at ChildProcess.onCpExit (/Users/synapse/.nvm/versions/node/v8.8.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:344:16)
gyp ERR! System Darwin 19.3.0
gyp ERR! command "/Users/synapse/.nvm/versions/node/v8.8.0/bin/node" "/Users/synapse/.nvm/versions/node/v8.8.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/synapse/Documents/synapsefi-dev-ui/node_modules/watchpack/node_modules/fsevents
gyp ERR! node -v v8.8.0
gyp ERR! node-gyp -v v5.0.3
npm WARN [email protected] No repository field.
npm WARN The package react-dropzone is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

What steps can I take to fix this compilation issue?

Same issue here after the Catalina update! Run xcode-select --reset first, then try installing again. The path gets screwed up sometimes and just needs a reset instead of a full reinstall. Fixed it for me when the regular install failed.

I encountered a similar situation after upgrading to Catalina, as new macOS versions can disrupt command line tools. To resolve the issue, I completely removed the existing command line tools and reinstalled them. Start by executing sudo xcode-select --install. If it indicates that the tools are already installed or if you experience any issues, you can uninstall them using sudo rm -rf /Library/Developer/CommandLineTools and then retry the installation. You can verify the installation with xcode-select -p to ensure the correct path is set. This process should resolve the gyp error, allowing it to recognize the Command Line Tools version.

Had this exact problem when I upgraded to Catalina last year. macOS updates break the connection between node-gyp and command line tools even when they’re installed. Here’s what fixed it for me: Run sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer if you’ve got Xcode, or sudo xcode-select --switch /Library/Developer/CommandLineTools if you only have command line tools. Then check gcc --version to make sure the compiler’s accessible. Basically, node-gyp can’t find the dev tools because Catalina changed some paths. Once I ran that switch command, npm installs worked fine again.