npm is the default package manager for Node.js. It is written entirely in JavaScript, and allows to install and distribute mostly JavaScript modules on the registry. Packages are treated in the CommonJS format, and are recognizable by the presence of a package.json
file.
prepublish
: Run before the package is publishedpublish
, postpublish
: Run after the package is publishedpreinstall
: Run before the package is installedinstall
, postinstall
: Run after the package is installedpreversion
, version
: Run before bump the package versionpostversion
: Run after bump the package versionpretest
, test
, posttest
: Run by the npm test
commandprestop
, stop
, poststop
: Run by the npm stop
commandprestart
, start
, poststart
: Run by the npm start
commandprerestart
, restart
, postrestart
: Run by the npm restart
command. Note: npm restart
will run the stop and start scripts if no restart
script is provided.It can be deduced that the "scripts"
property in package.json
is a very powerful tool. It can be used as a build tool, similar to the likes of Grunt and Gulp, but with over 250,000 packages available. NPM scripts runs npm packages installed locally to your project from the node_modules/.bin
directory.