- Modern JavaScript Web Development Cookbook
- Federico Kereki
- 132字
- 2021-07-02 14:50:04
How to do it...
We will want to install and configure nodemon, which will take care of everything for us, running updated code as necessary. First, obviously, we must install the mentioned package. You could do it globally with npm install nodemon -g, but I'd rather do it locally:
npm install nodemon --save-dev
Then, we'll need to add a couple of scripts:
- npm start will build the application and run our main file
- npm run nodemon will start the monitoring
"scripts": {
"build": "flow-remove-types src/ -d out/",
"buildWithMaps": "flow-remove-types src/ -d out/ --pretty --
sourcemaps",
"start": "npm run build && node out/doroundmath.js",
"nodemon": "nodemon --watch src --delay 1 --exec npm start",
.
.
.
},
Now, we are ready to monitor our application for changes, and restart it as needed!