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
bin
command 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>
inbundledDependencies
npm build <bundledDependencyFolder>
(without rebuild bundles)
- for each
npm run install
npm run postinstall
npm run preinstall
- for each
<dependency>
independencies
,devDependencies
,optionalDependencies
npm install <dependency>
npm build .
(without scripts)npm run install
npm run postinstall
npm run prepublish
(deprecated since npm 5)npm run prepare
- creates/updates
package-lock.json
ornpm-shrinkwrap.json
file
- 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
,optionalDependencies
npm 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
bin
command 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 prepare
npm run prepack
- create the
<package-name>-<package-version>.tgz
file. npm run postpack
npm run prepublish
(deprecated since npm 5)npm run prepare
npm run prepublishOnly
npm pack
(without runningprepublish
andprepare
scripts; already run)- publish to NPM registry
npm run postpublish
npm run pretest
npm run test
npm run posttest
npm run prestart
npm run start
npm run poststart
npm run prerestart
npm run restart
npm run postrestart
npm run prestop
npm run stop
npm run poststop