Adding the test-watch script

Let's go ahead and fill out the basics first. We'll set test equal to an empty string for the moment, and test-watch. The test-watch script, as we know, simply calls nodemon, calling the npm test script, nodemom --exec, then npm test inside single quotes:

"scripts": {  "start": "node server/server.js",  "test": "",  "test-watch": "nodemon --exec 'npm test'"},

This will get the job done. Now when we run nodemon here, we're actually running the globally-installed nodemon; we can also install it locally to fix that.

To get that done, all we're going to do is run npm install nodemon, add the most recent version, which is version 1.17.2, and use the --save-dev flag to install it:

npm install nodemon@1.17.2 --save-dev ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.