gyp ERR! build error / gyp ERR! find Python: node-gyp rebuild failed during npm install, how to fix it
gyp ERR! build error, gyp ERR! find Python or gyp ERR! stack Error: not found: make means npm install tried to compile a native addon such as bcrypt, sqlite3 or sharp, and the machine has no Python, make or C++ compiler. It usually happens because no prebuilt binary fits your Node version or platform (Alpine/musl included). Upgrade to a release with prebuilt binaries, switch to a pure-JavaScript package such as bcryptjs, or install the build tools.
By Livops team, the people who build and run LivopsUpdated
As it appears in a deploy log (shortened; example-addon stands for the package being compiled). Current npm prints the script’s output under its own npm error lines[9][10], so every gyp ERR! line starts with npm error:
npm error code 1
npm error path /app/node_modules/example-addon
npm error command failed
npm error command sh -c node-gyp rebuild
npm error gyp ERR! find Python
npm error gyp ERR! find Python --python was not set on the command line
npm error gyp ERR! find Python Python is not set from environment variable PYTHON
npm error gyp ERR! find Python checking if "python3" can be used
npm error gyp ERR! find Python - "python3" is not in PATH or produced an error
npm error gyp ERR! find Python checking if "python" can be used
npm error gyp ERR! find Python - "python" is not in PATH or produced an error
npm error gyp ERR! find Python You need to install the latest version of Python.
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Could not find any Python installation to use
npm error gyp ERR! not ok
With Python present but no build tools, the same block ends like this instead (shortened)[3][5][7]:
npm error gyp ERR! build error
npm error gyp ERR! stack Error: not found: make
npm error gyp ERR! System Linux 6.8.0
npm error gyp ERR! node -v v24.11.0
npm error gyp ERR! not ok
This page explains what node-gyp does during npm install, the four causes in the order they usually happen, and the fix for each, starting with the ones that need no compiler at all.
What does the error mean?
npm is compiling a native addon
node-gyp is the tool that compiles native addons, Node.js packages with C or C++ code in them[1]. When a package has a binding.gyp file and no install or preinstall script of its own, npm makes its install step node-gyp rebuild[8]. rebuild runs three commands in a row: clean, configure and build[4]. Each failure names its step:
gyp ERR! configure errorwithfind Pythonlines above it:configureneeds Python and found none. node-gyp checks the--pythonoption, thePYTHONvariable, thenpython3andpythonon thePATH, and stops withCould not find any Python installation to use[2]. It needs Python 3.6 or newer[2].gyp ERR! build errorwithnot found: make:buildrunsmakeon Linux and macOS, and looks it up on thePATHfirst[3];not found: makeis the lookup failing[7].gyp ERR! build errorwith`make` failed with exit code:makeran, but the compile itself failed[3]. The compiler’s own error is in the lines above, often a missingg++or a missing system library.
Every gyp line starts with gyp and the level, ERR! for errors, then the step’s own prefix such as find Python[6]. After the error, node-gyp prints the system, the Node version and its own version, then not ok[5]. Those lines are worth reading: an unexpected node -v is cause 3 below.
Why it happens on a server and not on your laptop
Most native packages do not expect you to compile them. They ship prebuilt binaries for common platforms and compile only when none fits: sqlite3 downloads a prebuilt binary for your platform if one exists, and otherwise builds with node-gyp, which needs a C++ compiler and linker[15]. bcrypt publishes prebuilt binaries for Windows, Linux (glibc and musl) and macOS, on x64 and arm64[13]. So a compile, and with it this error, usually means no prebuilt binary matched, and the machine has no build tools to fall back on.
Causes, most common first
1. No prebuilt binary for your Node version
Prebuilt binaries are made for the Node versions that existed when the package was released. bcrypt’s README says its binaries are best-effort, that there may be an interval between a release and its compiled modules, and that Node 18 onwards needs bcrypt 6.0.0 or later[13]. An old version of a native package on a new Node compiles from source.
Fix: upgrade the package to a current release, which has binaries for current Node versions:
npm install bcrypt@latest
npm ls bcrypt # check which version is actually installed
Packages built on Node-API need no binary per Node version: sqlite3 5 and later work this way, and its prebuilt binaries should work on Node 20.17.0 and later[15]. If you cannot upgrade the package yet, pin a Node version it has binaries for, for example in .nvmrc.
2. A package that never needed compiling: switch to a pure-JavaScript one
Where a pure-JavaScript package does the same job, there is nothing to compile on any machine:
-
bcrypt→bcryptjs. bcrypt.js is bcrypt in JavaScript with zero dependencies, compatible with the C++bcryptbinding; it is slower, about 30% by its own benchmark[14]. It has the samehashandcomparecalls[14]:npm uninstall bcrypt npm install bcryptjsimport bcrypt from "bcryptjs"; const hash = await bcrypt.hash(password, 10); const ok = await bcrypt.compare(password, hash); -
sqlite3. Its repository now says it is unmaintained[15]. Node itself has a built-innode:sqlitemodule, added in 22.5.0 and usable without a flag from 22.13.0, though still marked experimental there[16]. Check its stability in the Node docs before moving production code to it. -
sharp. Current sharp ships ready-compiled sharp and libvips binaries for the common platforms, Linux x64 and ARM64 with glibc or musl among them, and needs a Node-API v9 runtime such as Node 20.9.0 or later[17]. Building it from source is a separate step in its docs,npm explore sharp -- npm run build[17]. If its install still fails, its docs ask that your package manager installs optional dependencies, and warn that apackage-lock.jsonshared between platforms can cause installation problems[17].
3. No Python
The machine has no Python 3, or node-gyp cannot find it. Fix: install it, or point node-gyp at it[1][2]:
# Debian or Ubuntu
apt-get update && apt-get install -y python3
# Alpine
apk add --no-cache python3
# or tell node-gyp where it is
PYTHON=/usr/bin/python3 npm install
node-gyp run by hand also takes --python /path/to/python, and NODE_GYP_FORCE_PYTHON overrides every other setting[1].
Python 3.12 and later need node-gyp 10 or newer[1]. npm bundles node-gyp 10 from npm 10.3.0[11], so with an older npm and a new Python, update npm (npm install -g npm@latest).
4. No make or C++ compiler (and Alpine)
Python was found, but make or the compiler was not. node-gyp needs, on Unix, Python, make and a C/C++ toolchain such as GCC; on macOS, the Xcode Command Line Tools (xcode-select --install), which bring clang, clang++ and make[1]. On Windows it needs Python and the Visual Studio C++ build tools, for example choco install python visualstudio2026-workload-vctools -y[1].
Slim and Alpine images are where this happens most. node:slim contains only the minimal packages needed to run node[18]. node:alpine uses musl instead of glibc, and applications built for Debian (glibc) generally do not run on it[18], so a binary must be built for musl. Based on the multistage example in the Node.js Docker images’ best practices[19]:
FROM node:22-alpine AS builder
WORKDIR /app
RUN apk add --no-cache python3 make g++
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
FROM node:22-alpine
WORKDIR /app
COPY --from=builder /app ./
CMD ["node", "server.js"]
The compilers stay in the first stage, and the compiled node_modules is copied into the image that runs[19]. Build and run on the same base (both Alpine here), so the binary matches the C library. On Debian-based images the equivalent is apt-get install -y python3 make g++.
How to confirm the fix locally
See the full compiler output, not only the summary. --foreground-scripts runs install scripts in the foreground, sharing their output with npm’s[12]:
rm -rf node_modules
npm ci --foreground-scripts
To reproduce the server, run the install in a container with the same Node version and base. A slim image has no compiler, so it shows whether your dependencies still need one:
docker run --rm -v "$PWD":/app -w /app node:22-slim npm ci
If it passes there, no package compiled, or it compiled with what the image has.
On Livops
- Where it shows. A failed install stops the deploy as
install_failed, with the error in the build log; the previous version keeps running. See Install failed. - A Tip line for
gyp ERR! find Python. The log ends with a Tip: line for this case. Packages likebcryptor an oldsqlite3compile C code: switch to a prebuilt one,bcryptjsinstead ofbcrypt, or otherwise add a Dockerfile to the project. - Node 22 or 24. Those are the Node versions Livops has, so pick package versions with binaries for them. Livops reads
.nvmrcand.node-version; setdevEngines.runtime.versioninpackage.jsonto 22 or 24 if you use it. - Your own Dockerfile. If the repository has a
Dockerfile, it is used, and the build tools are whatever it installs, as in the example above. When Livops also recognises a framework in the project,builderinlivops.json(dockerfileorpreset) decides which one builds it; it is read when the project is created. See Frameworks and livops.json. - The assistant explains. Next to the failed build, the assistant’s button reads the log and tells you what happened and how to fix it. See AI assistant.
If the install stops earlier, on a peer dependency conflict, see npm ERR! code ERESOLVE; for other failures that end in code 1, see npm error code 1.
Questions
What is node-gyp and why does npm install run it?
node-gyp compiles native addons, packages written partly in C or C++. When a package has a binding.gyp file and no install script of its own, npm runs node-gyp rebuild for it during the install. Many native packages first try to use a prebuilt binary and call node-gyp only when none fits.
What does gyp ERR! find Python mean?
node-gyp looked for Python, which it needs to generate the build files, and found none it could use. It checks the --python option, the PYTHON variable, then python3 and python on the PATH. Install Python 3, or point node-gyp to it with the PYTHON environment variable.
What does gyp ERR! stack Error not found make mean?
Python was found and the build files were generated, but the make command is not on the PATH. On Linux, node-gyp needs make and a C and C++ compiler such as GCC. Install them, for example python3, make and g++, or avoid the compile with a package that ships a prebuilt binary.
Can I use bcryptjs instead of bcrypt?
Yes, in most apps. bcryptjs is pure JavaScript with zero dependencies, its README says it is compatible with the C++ bcrypt binding, and it never compiles anything. It is slower, about 30 percent by its own benchmark, which matters only for very high login volumes.
Why does it compile on the server but not on my laptop?
Prebuilt binaries are chosen by platform, CPU, C library and Node version. Your laptop may match a binary the package ships while the server, for example Linux on Alpine with musl, or a newer Node, does not. Then the package falls back to compiling, and the server has no compiler.
Does Python 3.12 break node-gyp?
Old versions of it. The node-gyp README says Python 3.12 and later need node-gyp 10 or newer. npm bundles node-gyp 10 or newer from npm 10.3.0, so updating npm is the fix.
Sources
- node-gyp — README (github.com). Checked .
- node-gyp source — lib/find-python.js (github.com). Checked .
- node-gyp source — lib/build.js (github.com). Checked .
- node-gyp source — lib/rebuild.js (github.com). Checked .
- node-gyp source — bin/node-gyp.js (github.com). Checked .
- node-gyp source — lib/log.js (github.com). Checked .
- which (npm) source — lib/index.js (github.com). Checked .
- npm Docs — scripts (docs.npmjs.com). Checked .
- npm source — lib/utils/error-message.js (github.com). Checked .
- @npmcli/promise-spawn source — lib/index.js (github.com). Checked .
- npm 10.3.0 source — package.json (bundled node-gyp) (raw.githubusercontent.com). Checked .
- npm Docs — config (foreground-scripts) (docs.npmjs.com). Checked .
- bcrypt (node.bcrypt.js) — README (github.com). Checked .
- bcrypt.js (bcryptjs) — README (github.com). Checked .
- node-sqlite3 — README (github.com). Checked .
- Node.js Docs — SQLite (node:sqlite) (nodejs.org). Checked .
- sharp — Installation (sharp.pixelplumbing.com). Checked .
- Node.js Docker images — README (github.com). Checked .
- Node.js Docker images — Best Practices (node-gyp alpine) (github.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your Node appRelated
- npm ERR! code ERESOLVE unable to resolve dependency tree: how to fix itnpm ERR! code ERESOLVE, unable to resolve dependency tree (npm error ERESOLVE in newer npm) means two packages in your project need versions of a shared peer dependency that cannot both be met. Since npm 7 installs peer dependencies, it stops instead of guessing. The real fix is to make the versions match: upgrade the package that is behind, or use the version it supports. --legacy-peer-deps and --force only skip the check.
- npm failed with return code 1 (npm ERR! code 1): how to fix the buildnpm failed with return code 1, or npm install exited with 1, is npm ERR! code 1 in newer npm: it only says that a script npm ran exited with code 1. The real error is printed above it: usually a compile or type error, a lockfile out of sync with package.json, or a dependency whose install script failed. Find the first error line above code 1, fix that, and the build passes.
- pip: Failed building wheel / failed-wheel-build-for-install — how to fix itpip found no ready-made wheel for a package on your Python version and platform, tried to compile one from source, and the compiler step failed. The fix is almost never to install a compiler: move to a version of the package that ships a wheel for your Python, switch to its binary variant (psycopg[binary], psycopg2-binary), or pin the Python version the package supports.
- exec format error in Docker: the image was built for another CPUThe kernel refused to run the container's program because it is not an executable for this machine: almost always a binary or image built for arm64 (an Apple Silicon Mac) running on an amd64 server, or the reverse. Build for the server's platform with --platform linux/amd64, or as a multi-platform image; if the file is a script, give it a #! line.
- Error: Cannot find module (MODULE_NOT_FOUND) in Node.js: how to fix itError: Cannot find module 'x' with code MODULE_NOT_FOUND, or ERR_MODULE_NOT_FOUND with import, means Node.js looked for a package or file and it was not there. On a server the usual causes are a package missing from package.json, a devDependency the install skipped, a path whose case differs from the file, a start command pointing at a file that was never built, or an ES module import without its .js extension.
- Node.js hosting in 2026: how to deploy an Express appA Node.js server in production needs one long-running process that listens on the port it is given, restarts when it crashes and exits cleanly on SIGTERM. On Livops you push a repository with package.json and it runs as a web app for 39 credits a month (39,000 so'm). Here is what Node needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.
- Error: Could not load the "sharp" module using the linux-x64 runtime — how to fix itCould not load the "sharp" module using the linux-x64 runtime means sharp found no prebuilt binary for the Linux machine it runs on. Since sharp 0.33 that binary is a separate optional package, @img/sharp-linux-x64, and it goes missing when node_modules was installed on a Mac or Windows and copied over, when the lockfile was made on another platform, or when optional dependencies were skipped. Install on the Linux machine with optional dependencies included, or add the Linux package to the lockfile.
- bcrypt_lib.node: invalid ELF header — why bcrypt fails in Docker and on Linuxinvalid ELF header, with code ERR_DLOPEN_FAILED, means Node on Linux tried to load a bcrypt binary that is not a Linux library: node_modules was installed on a Mac or Windows and then copied to the server, by a COPY . . without a .dockerignore or a committed node_modules folder. Keep node_modules out of the image and the repository and install inside Linux with npm ci, or switch to bcryptjs, which has no binary at all.
- error: linker `cc` not found (No such file or directory, os error 2) when building Rust: how to fix iterror: linker `cc` not found with note: No such file or directory (os error 2) means rustc compiled your code and then could not find the C compiler it uses to link it. On Linux, rustc calls cc as its linker driver, and a fresh machine or a slim container may have none. Install a C compiler (build-essential on Debian and Ubuntu, gcc and musl-dev on Alpine), or build in the official rust Docker image, which ships gcc.