How to auto-reload files in Node.js?

A good, up to date alternative to supervisor is nodemon:

Monitor for any changes in your node.js application and automatically restart the server – perfect for development

To use nodemon with version of Node without npx (v8.1 and below, not advised):

$ npm install nodemon -g
$ nodemon app.js

Or to use nodemon with versions of Node with npx bundled in (v8.2+):

$ npm install nodemon
$ npx nodemon app.js

Or as devDependency in with an npm script in package.json:

"scripts": {
  "start": "nodemon app.js"
},
"devDependencies": {
  "nodemon": "..."
}

Leave a Comment