Home > Software engineering >  Nodemon not restarting on file change
Nodemon not restarting on file change

Time:01-22

  "scripts": {
    "start": "npm run prod",
    "build": "npm-run-all clean transpile",
    "server": "node ./dist/bin/www",
    "dev": "npm run lint && NODE_ENV=development nodemon --inspect=notifications:9236 --exec babel-node bin/www",
    "prod": "NODE_ENV=production npm-run-all build server",
    "transpile": "babel ./ --out-dir dist",
    "lint": "eslint '*.js' ",
    "lint:watch": "watch 'npm run lint' ",
    "precommit": "npm run lint",
    "prepush": "npm run lint",
    "clean": "rimraf dist",
    "test": "jest"
  }

I have multiple microservices on docker, each one contains similar scripts in their package.json. Whenever I make a change and save the file, nodemon does not detect the change & restart the server.

Nodemon does start when a microservice is booted up, outputting the following:

[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): **/* public/**/*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node --inspect=notifications:9236 bin/www`

I have to mention, this is a project built on Mac OS and I am currently running it on Windows, if it is any relevant.

CodePudding user response:

In whatever start script you are trying to run, you need to include nodemon

ex:

"start": "nodemon run prod"

CodePudding user response:

Maybe it’s already the case, but do you have your code folder as a volume ? Because if you don’t use a volume to share your local changes with the dockerized files, it won’t update because the files will stay the same

CodePudding user response:

It's relevant on windows, because the file system difference in containers that run unix Duplicate question

if you setup nodemon.json

{
 "verbose": true,
 "watch": ["src/**/*.ts"],
 "exec": "ts-node ./src/index.ts",
 "pollingInterval": 100,
 "legacyWatch": true
}
  •  Tags:  
  • Related