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 ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error