This error indicates that macOS Command Line Tools are missing, which are required for compiling native Node.js modules. Install them using xcode-select to resolve the issue.
Fixes npm ERR! gyp ERR! stack Error: `xcode-select --install` to install the command line tools
xcode-select --installxcode-select --installnpm ERR! gyp ERR! stack Error: `xcode-select --install` to install the command line tools
On this page
This error occurs when npm attempts to build a native Node.js module but can't find the necessary compilation tools on your macOS system. Native modules (written in C/C++) need a compiler and related build tools to install. On macOS, these are provided by the Xcode Command Line Tools package, which includes clang, make, and other essential development utilities. The error message helpfully tells you exactly what command to run to fix it.
Run the installation command:
xcode-select --installA dialog will appear asking you to install the tools. Click "Install" and wait for the download to complete (may take several minutes depending on your internet connection).
After installation completes, verify the tools are working:
xcode-select -pThis should output something like:
/Library/Developer/CommandLineToolsAlso verify gcc is available:
gcc --versionNow retry your package installation:
npm installNative modules should compile successfully.
If the Command Line Tools installation fails or is corrupted, remove and reinstall:
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --installThis forces a fresh installation.
If you have full Xcode installed, you may need to set the correct developer directory:
sudo xcode-select --switch /Library/Developer/CommandLineToolsOr to use Xcode's tools:
sudo xcode-select --switch /Applications/Xcode.app/Contents/DeveloperFor headless CI environments, you can install Command Line Tools non-interactively:
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
softwareupdate -i -a
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progressThe Command Line Tools package is about 500MB-1GB, so ensure sufficient disk space.