The 'gyp ERR! find Python' error occurs when npm tries to build native C/C++ modules but cannot locate Python on your system. Node-gyp requires Python 3.6+ to compile packages like bcrypt, canvas, and sqlite3.
When you install a package that contains C/C++ source code, npm uses node-gyp to compile that code for your platform. Node-gyp depends on Python to generate and execute compilation commands. If Python is missing or npm cannot locate it, the build fails with this error.
First, check if Python is installed:
python3 --versionOn macOS:
xcode-select --install
# or
brew install python3On Linux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install python3 make g++On Windows:
Download Python from python.org and check 'Add Python to PATH' during installation.
Or use npm's built-in tool:
npm install --global windows-build-toolsTell npm where to find your Python installation:
# macOS/Linux
npm config set python $(which python3)
# Windows
npm config set python C:\\Users\\YourUsername\\AppData\\Local\\Programs\\Python\\Python311\\python.exeConfirm Python is properly configured:
python3 --versionMust be Python 3.6.0 or later. Then retry:
npm installIf using Alpine Linux image, add Python:
FROM node:16-alpine
RUN apk add --no-cache python3 py3-pip make g++
RUN npm config set python /usr/bin/python3
RUN npm installNode-gyp requires not just Python, but also a C/C++ compiler toolchain. On Windows, this means Visual Studio Build Tools. On macOS, the Xcode Command Line Tools. On Linux, gcc and g++ from build-essential. Modern node-gyp versions (v10+) support Python 3.12. Setting npm config is persistent across sessions.
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