NPM install lifecycle scripts (preinstall, install, postinstall) not being called for your package?

If you just added one of these lifecycle scripts to your package and published the changes to a registry:

In package-lock.json of the project that consumes your package as a dependency, ensure your package has "hasInstallScript": true. On npm ci or npm install, npm looks for the existence of this flag in package-lock.json rather than scanning each library’s package.json for “preinstall”, “install”, or “postinstall” scripts.

If your package is part of an organization, then it may be due to this bug: https://github.com/npm/cli/issues/4821

Or this bug: https://github.com/npm/cli/issues/5380

For what it’s worth, I am using both a custom registry with packages under an organization.

0 thoughts on “NPM install lifecycle scripts (preinstall, install, postinstall) not being called for your package?”

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: