What Are NPM Scripts?

An npm script is a convenient way to bundle common shell commands for your project. They are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application.

Scripts are stored in a project's package.json file, which means they're shared amongst everyone using the codebase. They help automate repetitive tasks, and mean having to learn fewer tools. Node npm scripts also ensure that everyone is using the same command with the same flags.

Common use cases for npm scripts include building your Node project, starting a development server, compiling CSS, linting, minifying, or anything else you find yourself typing into your terminal frequently that's related to your project.

In this tutorial we'll:

  • Learn what an npm script is in Node
  • Learn how to run scripts with npm
  • Explain the difference between custom and default scripts

By the end of this tutorial, you'll know what npm scripts are, and when you might want to use them with your project.

Log in or Sign up to view the complete tutorial.

Sign in with your Osio Labs account
to gain instant access to our entire library.