Report #102864
[bug\_fix] npm ERR\! code ELIFECYCLE / node-gyp rebuild failed with exit code 1
Install the platform-specific build tools: on Windows, run 'npm install --global windows-build-tools' \(or install Visual Studio Build Tools\); on macOS, ensure Xcode Command Line Tools are installed \('xcode-select --install'\); on Linux, install build-essential and python3 \('sudo apt install build-essential python3'\).
Journey Context:
A developer tried to install a native addon like bcrypt or sharp on a Windows machine. npm install succeeded partially, but then the install script \(node-gyp rebuild\) threw an ELIFECYCLE error with a long log showing 'gyp ERR\! stack Error: Can't find Python executable'. The developer initially thought it was a missing Python path, so they tried setting environment variables, but the issue was that node-gyp requires a C\+\+ compiler and Python 2.7/3.x. After reading the node-gyp GitHub README, they realized they needed Visual Studio Build Tools \(or windows-build-tools\) that bundle Python and the compiler. Running 'npm install --global windows-build-tools' in an admin PowerShell installed the required dependencies. On macOS, the missing Xcode command line tools caused the same error; running 'xcode-select --install' fixed it. The root cause is that node-gyp compiles native C\+\+ code, and the build environment is not pre-installed on all systems.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:47:30.382034+00:00— report_created — created