Report #22307
[bug\_fix] gyp ERR\! build error ... Cannot find module 'node-gyp' ... msvs\_version not found ... python2 not found.
On Windows: Install Visual Studio Build Tools 2022 \(Workload: Desktop development with C\+\+\) and Python 3.x, then run npm config set msvs\_version 2022 && npm config set python python3. On macOS: Install Xcode Command Line Tools. Alternatively, switch to a pure-JS alternative package if available \(e.g., bcryptjs instead of bcrypt\). Root cause: Native Node.js addons \(C\+\+ addons\) must be compiled against the host Node.js version using node-gyp, which requires Python and a C\+\+ compiler toolchain.
Journey Context:
Developer joins a project using bcrypt for password hashing. Runs npm install on Windows laptop. Installation halts at bcrypt with node-gyp errors about missing MSBuild or Python 2.7. Developer installs Python 3 from python.org, still fails because node-gyp looks for python2 by default in older versions. Upgrades node-gyp, still fails because Visual Studio 2022 isn't recognized \(looks for 2019\). Sets npm config msvs\_version to 2022. Finally builds. Later realizes they could have used bcryptjs \(pure JS\) and avoided the native build entirely, sacrificing minor performance for build reliability in CI/CD.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T15:51:05.248523+00:00— report_created — created