4

I would like to restart automatically my local strongloop/loopback app when js & json are modified. I am testing with nodemon but the app is always restarting even if js or json are not modified.

Is there an alternative for solving this problem ?

Thanks, Christophe

Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
Christophe
  • 71
  • 1
  • 2

3 Answers3

9

if you would like to run the project with nodemon just add dev command under the script json object and add additional config json inside of the package.json file.

"scripts": {
  ...
  "dev" : "nodemon src/index.ts",
  ...
},
"nodemonConfig": {
  "verbose": true,
  "watch": [ "src/" ],
  "ignore": [ "dist/*" ],
  "ext": "ts",
  "exec": "npm start"
},

and then run the project with command npm run dev.

Neeraj Tangariya
  • 1,159
  • 1
  • 17
  • 29
Amr Omar
  • 399
  • 5
  • 12
4

You can do it in few steps:

  1. install nodemon: npm i --save-dev nodemon
  2. open package.json in section scripts add new line: "dev" : "nodemon server/server.js --watch common --watch server"
  3. run your server with command: npm run dev

Each time when You change something in folders: common or server nodemon will restart application with provided changes.

Nazarii Iaremii
  • 133
  • 3
  • 8
0

Maybe there is another file that is constantly changing that nodemon is monitoring. If so, you can use the --ignore command. For example Nodemon - exclusion of files

Community
  • 1
  • 1
Ryan Dobbs
  • 381
  • 2
  • 11