node-gyp "Could not find any Python installation" - Fix Native Builds in CI
node-gyp drives native addon builds and requires a Python interpreter to run its build scripts. On a slim CI image with no Python, it aborts before compiling anything.
What this error means
A native module install fails early with gyp ERR! find Python / Could not find any Python installation to use. The package has no prebuilt binary for this platform and falls back to a source build that node-gyp cannot start without Python.
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python You need to install the latest version of Python.
npm error code 1Common causes
No Python on the runner image
Minimal/slim and some Alpine images ship no Python. node-gyp cannot run its configure/build step without it.
Python present but not discoverable
Python exists under a non-standard name/path that node-gyp does not auto-detect, so it reports none found.
How to fix it
Install Python and point node-gyp at it
Add Python (plus a compiler) and, if needed, tell node-gyp where it is.
# Debian/Ubuntu
apt-get update && apt-get install -y python3 make g++
# Alpine
apk add --no-cache python3 make g++
# if auto-detect fails:
npm config set python "$(command -v python3)"
npm ciPrefer a prebuilt path
- Use a base image that already ships Python and build tools.
- Pick a Node major / libc the package publishes prebuilds for so no source build is needed.
- Cache compiled node_modules per platform to avoid rebuilding each run.
How to prevent it
- Use CI images with Python + a C/C++ toolchain for native deps.
- Match image to available prebuilds to skip source builds.
- Set
npm config set pythonwhen discovery is unreliable.