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.
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.
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm
npm error code E403 npm error 403 Forbidden - PUT https://registry.npmjs.org/<package>
How to fix 'E403 Forbidden' error in npm
npm ERR! code EUSAGE npm ERR! Usage error
How to fix "npm ERR! code EUSAGE" in Node.js projects
npm ERR! code E401 npm ERR! 401 Unauthorized
How to fix "E401 Unauthorized" in npm