The 'gyp ERR! configure error' occurs when npm fails to compile native Node.js modules due to missing system dependencies, build tools, or Python. This happens during npm install when a package requires compilation.
Node-gyp is a tool that compiles native C/C++ modules for Node.js packages. When you run npm install, gyp attempts to configure and build these native modules using your system's C++ compiler and Python. The 'configure error' means gyp failed to validate or set up your build environment—typically because required build tools, compilers, or Python are missing.
Start with a clean slate:
npm cache clean --force
rm -rf node_modules package-lock.jsonEnsure you're using a stable version:
node --versionUpgrade to the latest LTS from https://nodejs.org or use nvm:
nvm install --lts
nvm use --ltsWindows (PowerShell as Administrator):
npm install --global --production windows-build-toolsAlternatively, install Visual Studio Build Tools with 'Desktop development with C++' workload.
macOS:
xcode-select --installLinux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install build-essential python3Check Python is accessible:
python3 --version
which python3Configure npm to use Python:
npm config set python python3Ensure you have the latest node-gyp:
npm install --global node-gyp@latestOnce build tools are installed:
npm installOn Docker/containers, base images often lack build tools—add them in your Dockerfile: RUN apt-get install -y build-essential python3. In CI/CD environments, ensure your runner has access to compilers. Some organizations use pre-built binary caches to avoid recompilation entirely. Windows-build-tools installation requires ~3GB disk space and Administrator privileges.
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