This error occurs when building native Node.js modules on macOS and you haven't accepted the Xcode license agreement. The fix requires running a simple command with admin privileges to accept the license.
This error appears when npm tries to compile native Node.js modules (like node-gyp, bcrypt, or sharp) on macOS, but the Xcode Command Line Tools license hasn't been accepted yet. macOS requires explicit acceptance of Apple's license agreement before development tools can be used. Native modules that need compilation rely on these tools, so the build process fails until the license is accepted. This commonly happens after installing or updating Xcode, upgrading macOS, or on fresh developer machine setups.
Run the following command to accept the Xcode license agreement:
sudo xcodebuild -license acceptYou'll need to enter your admin password. This accepts the license non-interactively.
If you want to read the license first:
sudo xcodebuild -licenseScroll through the license text (press Space), then type "agree" at the prompt.
Make sure the Command Line Tools are properly installed:
xcode-select --installIf they're already installed, you'll see a message saying so. Otherwise, follow the GUI prompts.
After accepting the license, retry your installation:
npm installNative modules should now compile successfully.
If you have multiple Xcode versions installed, ensure the correct one is selected:
sudo xcode-select -s /Applications/Xcode.app/Contents/DeveloperFor CI/CD pipelines on macOS, include the license acceptance step in your setup:
- run: sudo xcodebuild -license acceptIf you only need Command Line Tools (not full Xcode), you can install them standalone and they have a simpler license process. However, some native modules may still require full Xcode.
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