Report #97643
[bug\_fix] ELIFECYCLE CompileError: node-gyp rebuild failed: gyp: No Xcode or CLT version detected
Install Xcode Command Line Tools via \`xcode-select --install\` or set \`xcode-select -p\` to the correct path, then clean and rebuild native addons.
Journey Context:
On a fresh macOS Sonoma, I ran \`npm install\` and it started building \`node-canvas\` \(a native module\). The build failed with ELIFECYCLE and a long stack trace ending with \`gyp: No Xcode or CLT version detected\`. I had Xcode installed but the CLI tools path was missing. Running \`xcode-select --install\` said they were already installed, but \`xcode-select -p\` returned \`/Library/Developer/CommandLineTools\`. That path didn’t have the correct SDK symlinks. I tried \`sudo xcode-select --reset\` – no change. The actual fix was to reinstall CLTs: \`sudo rm -rf /Library/Developer/CommandLineTools\` and then \`xcode-select --install\`. After that, \`node-gyp rebuild\` succeeded. The root cause: macOS updates sometimes shift SDK paths, and node-gyp relies on \`xcrun\` which checks CLT version. Without a proper SDK, the C\+\+ compilation fails. I also learned that setting \`npm\_config\_node\_gyp\` or using \`node-gyp rebuild --nodedir\` with a local Node source directory can bypass this, but the cleaner fix is to ensure CLTs are correctly installed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:47:18.068938+00:00— report_created — created