Search code examples
node.jsdockernodemon

Nodemon not restarting on file change


  "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.


Solution

  • 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
    }