secret black magic you should use...


What is npm?

npm is the default package manager for the JavaScript runtime environment Node.js.



npm is a command line interface (CLI) tool

  • when you install Node.js, there is a bundled version of npm's CLI
  • that CLI is super versital and powerful
  • this is how you can interact with the entire npm ecosystem
  • but npm is hiding a secret, there is black magic in npm's CLI (and one of it's tricks is task running)



built in scripts

  • publish: when a package is published.
  • install: when a package is installed
  • uninstall: when a package is uninstalled.
  • version: when a version bump of a package version.
  • test: used to run tests for the package
  • stop: when the start command ends.
  • start: used to start the package.
  • restart: Used to restart the project and if there isn't one defined will run the stop and start scripts

phases of scripts!

For every script that you create there are 3 phases:

  • pre phase


  • the script itself


  • post phase

The big reveal...

If you would like to see what scripts are defined for you to run on any project (with a package.json).


Run :


npm run

stitching it all together...

So now that we have seen there are built in scripts and built in pre and post commands for all npm scripts default and custom created... we can almost create workflows and processes as part of these scripts...



Thanks & Goodnight

  • My name is Robbie Holmes
  • robbiethegeek everywhere on the interwebs
  • I work at the Department of Veterans Affairs for the United States Digital Service




npm scripts

By Robbie Holmes