package.json
allows you to run npm packages locally."karma": "karma"
script references the karma
shell script is the node_modules/.bin
directory. This reference needs to be grab and an alias needs to be applied to it in order to be used in other npm scripts, such as "test": "karma start"
.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.