The Node Package Manager (npm) and the package.json file in combination makes a great option for build automation. Using npm and package.json is simpler and has no extra dependencies such as Gulp and Grunt for example. It's easy to get started by moving your existing commands into the package.json and you can utilize the entire Node package library in your script.
Why should I even care about this when there's an abundance of great tools already? npm is baked into your process already. No build tools are needed and any command you run at the command prompt today can be moved into your package.json with one line of code. The Node package library, that you most likely are using anyway, is vast and contains just about anything you need for your automation. Keeping it in npm and package.json means that everyone can use it. No additional configuration is needed. Just npm install and then use the scripts. You now only have one place to keep updated.
Pre and Post Hooks As we start to use more and more scripts, we will soon find the need of structuring the execution of our scripts a bit. Luckily, npm has a few tools built in to do so. In this module, we will specifically check in on the pre and post hooks that help us to organize our scripts a bit.
Scripts for Development and Test Starting from this module and a couple of modules forward, we will change gears a little bit. So far, we learned about the basics and syntax and functionality of scripting with npm. We will now use those acquired skills to support us in different stages of the development cycle. In this module, we will create a few scripts that can be useful when we develop and test our application. I'll make sure to sneak in some tips and tricks in the progress, too.
Versioning, Pushing, and Deploying The last two modules focused on developing and testing, but an application that is not used by users is truly useless, I'm sure everyone agrees with. Therefore, in this module, we will take a look at writing a few scripts to support us in versioning, pushing to our repository, and deploying to our platform of choice. As we said, our scripts node is getting pretty long in the package. json by now. Remember that we can get a quick log of the available commands with npm run. This module focuses on the individual scripts, and in the next, we will put many things that we learned so far during the course together into a big deploy to production script. So, if you're missing a step here, like compiling, testing, bundling, before we're pushing to production, don't worry, that's in the next module. Let's hop to it.
npm as Build Script Summary This course set out with the assumption that we could npm and the package. json file as our build tool. This is the way that Node and npm themselves are built, and take away the dependencies on third-party products, such as Gulp and Grunt and all of their packages. To our help, we have the entire plethora of packages and tools that npm offers, the largest Open Source library in the world. Through the course, we have created a monstrously long package. json file with a lot of example scripts and ways that you can use the scripting capabilities of npm to your advantage.