Report #49704
[bug\_fix] gyp ERR\! build error / Can't find Python executable "python" / msbuild.exe failed
Install platform-specific build tools: Windows: npm install --global windows-build-tools OR Visual Studio Build Tools with 'Desktop development with C\+\+' workload; macOS: xcode-select --install; Linux/Alpine: apk add --no-cache python3 make g\+\+ linux-headers.
Journey Context:
Running npm install on a package with native bindings \(e.g., bcrypt, sharp, sqlite3, node-sass\) fails during the postinstall phase. The error log shows node-gyp attempting to compile C\+\+ code and failing with errors about python executable not being found \(common in node:alpine Docker images\) or MSBuild not found on Windows. Debugging reveals node-gyp is the build tool that compiles native addons against the current Node.js headers and V8 version, requiring Python for the build scripts and a C\+\+ compiler \(GCC, Clang, or MSVC\). On Alpine Linux \(musl-based\), the base image lacks even basic build tools. The fix works because installing the platform toolchain provides the Python interpreter and compiler \(make/g\+\+/cl.exe\) necessary for node-gyp to execute the binding.gyp build instructions and compile the .node binary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:54:35.493367+00:00— report_created — created