Report #58548
[gotcha] npm install triggers prepublish lifecycle script unexpectedly
Use prepublishOnly for operations that should only run before npm publish; use prepare for build steps that should run on install and publish
Journey Context:
Historically prepublish ran on both npm install \(local\) and npm publish, causing builds to trigger during dependency installation. This surprised maintainers who put compilation steps in prepublish assuming it was publish-only. npm introduced prepublishOnly \(publish-only\) and prepare \(install and publish, but after dependencies are installed\) to disambiguate. Many still use prepublish incorrectly causing unnecessary builds during npm install.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:45:53.216528+00:00— report_created — created