The Node.js ecosystem is full with useful CLI tools and most of them offer configurations that let you tune them to do exactly what you want. However, sometimes you still have the need for very custom configurations and scripts. This is where "npm scripts" come into place. While you might have used this to set up your "build", "dev" or "start" script, there's a lot of things you can do with them. In this blog post we'll talk about the most useful and some hidden features.

Before we get started, make sure you have the latest version of npm installed. While a lot of these things should work in yarn , berry and pnpm as well, we'll focus on npm in this article. Everything in this post has been tested with npm version 6.10.

What are npm scripts?

When we talk about "npm scripts" we are talking about entries in the scripts field of the package.json . The scripts field holds an object where you can specify various commands and scripts you want to expose. These can then be executed using npm run <script-name> .