You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The prepare script runs any time that the package needs to be prepared (built). For example, prepare runs when the package will be packed. When installing a library from a git repo for example, the prepare hook will run, and it will have access to devDependencies in NPM's local checkout for the purposes of being able to run build tools, etc. This way, once the git pakage is packed up, it will work as expect the same as if it were published to the npmjs.com registry.
It seems like postinstall is a better package.json hook because it runs in less situations, while prepare runs in a lot more that don't make as much sense.
The
prepare
script runs any time that the package needs to be prepared (built). For example,prepare
runs when the package will be packed. When installing a library from a git repo for example, theprepare
hook will run, and it will have access todevDependencies
in NPM's local checkout for the purposes of being able to run build tools, etc. This way, once the git pakage ispack
ed up, it will work as expect the same as if it were published to the npmjs.com registry.It seems like
postinstall
is a better package.json hook because it runs in less situations, whileprepare
runs in a lot more that don't make as much sense.F.e. base on the docs,
postinstall
runs when:npm ci
in a projectnpm install
in a projectnpm install --global <pkg name>
in the installed project? Not sure about this one, I have never relied on it.npm rebuild
On the other hand,
prepare
runs during all of the above, plus:npm cache add
npm diff
npm pack
npm publish
and it seems like we don't really need to run git hook installation during cache, diff, pack, or publish.
The text was updated successfully, but these errors were encountered: