The following describes the behaviour of several npm commands, particularly w.r.t. the scripts that are run in each, for NPM version 6.5.0.
npm run preinstall- link binaries (node-gyp)
- for each
bincommand in other package:- symlink
./node_modules/.bin/<bin-name>->./node_modules/<other-package>/<local-bin-path>
- symlink
- if (
config["rebuild-bundle"]) [=true]- for each
<bundledDependency>inbundledDependenciesnpm build <bundledDependencyFolder>(without rebuild bundles)
- for each
npm run installnpm run postinstall
npm run preinstall- for each
<dependency>independencies,devDependencies,optionalDependenciesnpm install <dependency>
npm build .(without scripts)npm run installnpm run postinstallnpm run prepublish(deprecated since npm 5)npm run prepare- creates/updates
package-lock.jsonornpm-shrinkwrap.jsonfile
- if
<dependency>is another package's identifier- fetch package into
./node_modules
- fetch package into
- if
<dependency>is another package's folder- symlink
./node-modules/<other-package-name>-><other-package-folder>(if is top-level?)
- symlink
<other-package>:npm run preinstall- for each
<dependency2>in<other-package>'sdependencies,devDependencies,optionalDependenciesnpm install <dependency2>
<other-package>:npm run prepare, if<dependency>is of type<git-remote-url-package><other-package>:npm build .(without scripts)<other-package>:npm run install<other-package>:npm run postinstall- save package as a dependency in
package.json, if top-level and [--save],--save-dev, ...
npm install- for each
bincommand in current package:- symlink
/usr/local/bin/<bin-name>->/usr/local/lib/node_modules/<package-name>/<local-bin-path>
- symlink
- symlink
/usr/local/lib/node_modules/<package-name>->.
<other-package>:npm link- symlink
./node-modules/<other-package-name>->/usr/local/lib/node_modules/<other-package-name>
<other-package>:npm run preuninstall- remove symlinks of dependency bins
<other-package>:npm run uninstall<other-package>:npm run postuninstall- remove package dependency in
package.json, if [--save],--save-dev, ...
npm run prepublish(deprecated since npm 5)npm run preparenpm run prepack- create the
<package-name>-<package-version>.tgzfile. npm run postpack
npm run prepublish(deprecated since npm 5)npm run preparenpm run prepublishOnlynpm pack(without runningprepublishandpreparescripts; already run)- publish to NPM registry
npm run postpublish
npm run pretestnpm run testnpm run posttest
npm run prestartnpm run startnpm run poststart
npm run prerestartnpm run restartnpm run postrestart
npm run prestopnpm run stopnpm run poststop