skip to Main Content
  "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.

4

Answers


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

    ex:

    "start": "nodemon run prod"
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. It’s relevant on windows, because the file system difference in containers that run unix Duplicate question

    if you setup nodemon.json to poll changes it should update, but it is very expensive memory wise

    {
     "verbose": true,
     "watch": ["src/**/*.ts"],
     "exec": "ts-node ./src/index.ts",
     "pollingInterval": 100,
     "legacyWatch": true
    }
    
    Login or Signup to reply.
  4. I’m watching files via nodemon --watch '**/*' this will finds any changes in the nested files

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search