Report #3629
[gotcha] npm lifecycle script prepare executes during local npm install, not just before publish
Use \`prepublishOnly\` for build steps that should only run before publishing. Use \`postinstall\` for native compilation that must run on the consumer's machine. Avoid \`prepare\` for heavy builds unless you intend for developers to rebuild on every install.
Journey Context:
The \`prepare\` script runs after \`npm install\` in a git repo \(since npm v4\) and before \`npm pack\`/\`publish\`. Developers often use it for build steps thinking it only runs before publish, causing unnecessary or failing builds during \`npm install\` in CI/CD or for consumers installing from git. This differs from \`prepublishOnly\` \(publish only\) and \`postinstall\` \(consumer install only\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:47:00.843332+00:00— report_created — created