npm npm scripts

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • The "scripts" property in package.json allows you to run npm packages locally.
  • The "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".

Remarks

Pre-recognized scripts

  • prepublish: Run before the package is published
  • publish, postpublish: Run after the package is published
  • preinstall: Run before the package is installed
  • install, postinstall: Run after the package is installed
  • preversion, version: Run before bump the package version
  • postversion: Run after bump the package version
  • pretest, test, posttest: Run by the npm test command
  • prestop, stop, poststop: Run by the npm stop command
  • prestart, start, poststart: Run by the npm start command
  • prerestart, 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.



Got any npm Question?