👉 Run a script with Nodemon
Nodemon is an NPM package that automatically restarts your node application when file changes in the directory are detected. Run the following in the Terminal:
- Run
npm install -g nodemon
to install the nodemon package globally
- Run
nodemon index.js
(instead of node)
- Edit
index.js
and save it. The nodemon process will see the change and run your code each time you save.
[nodemon] clean exit - waiting for changes before restart
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
Before proceding, exit from nodemon with ctl+c