Npm install executes certain scripts like preinstall
, postinstall
and others.
I couldn't find explicit list and ordering of these scripts. It would be great to get some clarification and detailed overview of this process.
It is described on the NPM page: npm-scripts. It is a bit cryptic, but the logic is straightforward.
E.g. running
npm install
will do preinstall install postinstall prepublish
- this is rather exceptional case, prepublish only runs if there are no arguments, i.e. run locally. Also check which version of npm you are running, as prepublish
with local install
has been deprecated in 4.x in favour of another approach, described in issue 10074 and has a nice explanation in this blog. It comes down to the fact that npm install
without arguments runs when you clone a package and it makes sense to prepare it. But people dislike this behaviour, so it was decided to split prepublish into two stages. prepare
runs instead of prepublish
during publishing and local npm install
. prepublishOnly
runs only with npm publish
.
Hence
npm publish
will do prepublish publish postpublish
or prepare prepublishOnly publish postpublish
on 4.x
Finally, with version 6.x, npm install
runs preinstall install postinstall prepare
while npm publish
runs prepare prepublish publish postpublish
.
As far as I know, all other commands follow the logic of preX
, X
, postX
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With