npm install stops while building a native module with node-gyp
gyp ERR! find PythonShort answer
node-gyp compiles native add-ons, so it needs a supported Python and a C/C++ compiler. The log shows which one is missing. Install the compiler tools for your system, point node-gyp at a supported Python, and use node-gyp 10 or newer if Python is 3.12 or later.
Fix it fast
1Find out which cause you have
Re-run the install with more detail and read the gyp lines above the final error. They list every Python it tried.
npm install --loglevel=verbose 2>&1 | grep -i gyp2Match what you see, then jump to its fix
- 1
Could not find any Python installation to useNo supported Python can be foundFix - 2
Found unsupported Python version, or errors from Python itself, with Python 3.12 or laterPython is too new for an old node-gypFix - 3
gyp ERR! build error, with make, gcc, g++ or clang not found; or on Windows, no Visual Studio foundThe C/C++ compiler or build tools are missingFix
- 1
What does the error look like?
gyp ERR! find PythonCould not find any Python installation to useFound unsupported Python versiongyp ERR! build error
Cause 1 of 3
No supported Python can be found
1Check
node-gyp tries a Python from the command line, the PYTHON variable, then python3 and python. It accepts 3.6 or newer. On Windows it also tries the py launcher and common install folders.
python3 --version
echo "$PYTHON"2Fix
Install a current Python, or tell node-gyp which one to use. NODE_GYP_FORCE_PYTHON overrides every other setting.
export npm_config_python=/usr/bin/python3
npm install3Verify
The install gets past the configure step.
npm install --loglevel=verbose 2>&1 | grep -i pythonConfirmed by github.com
Cause 2 of 3
Python is too new for an old node-gyp
1Check
If node-gyp is installed globally it reports its version. node-gyp's README says Python 3.12 or later needs node-gyp 10 or newer. A pinned old version of node-gyp breaks on it.
node-gyp --version
python3 --version2Fix
Install node-gyp 10 or later.
npm install -g node-gyp3Verify
The node-gyp version is 10 or higher.
node-gyp --versionConfirmed by github.com
Cause 3 of 3
The C/C++ compiler or build tools are missing
1Check
On Linux node-gyp needs make and a C/C++ toolchain, on macOS the Xcode Command Line Tools, on Windows Visual Studio with the Desktop development with C++ workload.
make --version
g++ --version
# macOS: xcode-select -p2Fix
Install the toolchain for your system.
# Ubuntu / Debian
sudo apt install build-essential
# macOS
xcode-select --install3Verify
Run the install again; compilation proceeds.
npm installConfirmed by github.com
How do I stop it coming back?
- Prefer packages that ship prebuilt binaries, and keep Node.js on an LTS line they support.
- Keep npm and node-gyp current so they match your Python.
- Document the build tools your project needs in its README or CI image.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
Related fixes
Back end
npm reports ELIFECYCLE, but the real error is somewhere else
npm ERR! errno 1
ELIFECYCLE is not the bug.
3 causes, each with a fixBack end
npm install fails because node-gyp cannot find Python
You need to install the latest version of Python.
node-gyp compiles native add-ons and needs a supported Python.
3 causes, each with a fixBack end
Application Load Balancer returns 502 for a Node.js target
HTTPCode_ELB_502_Count
An ALB returns 502 when the target gives it something it cannot use: a refused or reset connection, a connection closed mid-request, a bad response, or a header over 32 K.
4 causes, each with a fixBack end
corepack enable fails: permission denied while creating the pnpm link
Internal Error: EACCES: permission denied, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/usr/local/bin/pnpm'
corepack enable writes small link files for yarn and pnpm next to your node binary.
2 causes, each with a fixBack end
Create React App says Node is too old, and npm will not run on the new one
npm does not support Node.js v10.19.0
The shell is running an old Node.js that is below the version Create React App needs.
3 causes, each with a fixBack end
firebase deploy cannot load your functions: user code failed to load
Functions codebase could not be analyzed successfully. It may have a syntax or runtime error
The Firebase CLI loads your functions code on your machine before it deploys, to learn which functions exist.
4 causes, each with a fix