From the course: Angular: Creating and Hosting a Full-Stack Site

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Restart a Node server automatically

Restart a Node server automatically

From the course: Angular: Creating and Hosting a Full-Stack Site

Start my 1-month free trial

Restart a Node server automatically

- [Instructor] So you may have noticed that until now we've had to manually restart our server every time we make a change to our code in order for those changes to take effect. And wouldn't it be nice if our server could sense when our files changed and automatically restart itself? Well, as a matter of fact, there's an NPM package that does this for us, and it's called no demon. Let's install this package into our project like this. We're going to say npm install --savedev, nodemon and hit enter, and once that installs, all we have to do is change the command that we use to run our server. Instead of running npx babel-node src/server.js, we're going to write npx nodemon - -exec npx babel-node src/server.js. The command is a little longer, but it saves us a lot of work in the long run, and then hit enter, and what we're doing here is telling no demon to rerun whatever command we put after this exec flag, whenever…

Contents