question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nodemon doesn't reload under certain scenarios where two -w flags passed

See original GitHub issue

Nodemon doesn’t reload (as I think would be expected) in cases where:

  • There are two -w flags passed to it AND
  • The file referenced by the second -w flag exists AND
  • The file referenced by the first -w flag does not exist when nodemon is first started, but is created while nodemon is running
  • nodemon -v: 2.0.6
  • node -v: 14.5

I’ve created an environment for reproducing the issue in a public repo here:

https://github.com/acannon828/nodemon_issue

To reproduce the issue, the environment requires GNU make be installed, and that docker and docker-compose be installed. The README.txt in this repo includes steps on how to reproduce the issue, and what I think would be the expected behavior.

Here’s output from adding the --dump flag to the nodemon command I’m running in this repo:

server_1  | > nodemon --dump -C -w bin/index.js -w foo.txt
server_1  |
server_1  | [nodemon] 2.0.6
server_1  | [nodemon] to restart at any time, enter `rs`
server_1  | [nodemon] watching path(s): bin/index.js foo.txt
server_1  | [nodemon] watching extensions: js,mjs,json
server_1  | --------------
server_1  | node: v14.5.0
server_1  | nodemon: 2.0.6
server_1  | command: /usr/local/bin/node /usr/src/server/node_modules/.bin/nodemon --dump -C -w bin/index.js -w foo.txt
server_1  | cwd: /usr/src/server
server_1  | OS: linux x64
server_1  | --------------
server_1  | {
server_1  |   run: false,
server_1  |   system: { cwd: '/usr/src/server' },
server_1  |   required: false,
server_1  |   dirs: [ '/usr/src/server/foo.txt' ],
server_1  |   timeout: 1000,
server_1  |   options: {
server_1  |     dump: true,
server_1  |     runOnChangeOnly: true,
server_1  |     watch: [ 'bin/index.js', 'foo.txt', re: /bin\/index\.js|foo\.txt/ ],
server_1  |     ignore: [
server_1  |       '**/.git/**',
server_1  |       '**/.nyc_output/**',
server_1  |       '**/.sass-cache/**',
server_1  |       '**/bower_components/**',
server_1  |       '**/coverage/**',
server_1  |       '**/node_modules/**',
server_1  |       re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/
server_1  |     ],
server_1  |     monitor: [
server_1  |       'bin/index.js',
server_1  |       'foo.txt',
server_1  |       '!**/.git/**',
server_1  |       '!**/.nyc_output/**',
server_1  |       '!**/.sass-cache/**',
server_1  |       '!**/bower_components/**',
server_1  |       '!**/coverage/**',
server_1  |       '!**/node_modules/**'
server_1  |     ],
server_1  |     ignoreRoot: [
server_1  |       '**/.git/**',
server_1  |       '**/.nyc_output/**',
server_1  |       '**/.sass-cache/**',
server_1  |       '**/bower_components/**',
server_1  |       '**/coverage/**',
server_1  |       '**/node_modules/**'
server_1  |     ],
server_1  |     restartable: 'rs',
server_1  |     colours: true,
server_1  |     execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' },
server_1  |     stdin: true,
server_1  |     verbose: false,
server_1  |     signal: 'SIGUSR2',
server_1  |     stdout: true,
server_1  |     watchOptions: {},
server_1  |     execOptions: {
server_1  |       script: 'bin/index.js',
server_1  |       exec: 'node',
server_1  |       args: [],
server_1  |       scriptPosition: 0,
server_1  |       nodeArgs: undefined,
server_1  |       execArgs: [],
server_1  |       ext: 'js,mjs,json',
server_1  |       env: {}
server_1  |     }
server_1  |   },
server_1  |   load: [Function (anonymous)],
server_1  |   reset: [Function: reset],
server_1  |   lastStarted: 0,
server_1  |   loaded: [],
server_1  |   watchInterval: null,
server_1  |   signal: 'SIGUSR2',
server_1  |   command: {
server_1  |     raw: { executable: 'node', args: [ 'bin/index.js' ] },
server_1  |     string: 'node bin/index.js'
server_1  |   }
server_1  | }
server_1  | --------------
nodemon_issue_server_1 exited with code 0

Hope that helps!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
remycommented, Nov 25, 2020

Can you post the output when the file is touched (that should trigger a reload) with DEBUG=nodemon,nodemon:* nodemon … at the beginning - it’ll show why it was ignored.

0reactions
github-actions[bot]commented, Jul 9, 2021

Automatically closing this issue due to lack of activity

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nodemon doesn't reload under certain scenarios where two -w flags ...
Nodemon doesn't reload (as I think would be expected) in cases where: There are two -w flags passed to it AND; The file...
Read more >
nodemon/faq.md at main - GitHub
Sometimes when using the --inspect flag, nodemon will try to start the a process before the old process is finished. Your application will...
Read more >
Automatically restart Node.js apps with Nodemon
The essential tutorial for Nodemon, a utility for Node.js applications that monitors for changes and automatically restarts the server.
Read more >
Restart node upon changing a file - Stack Overflow
Nodemon will watch the files in the directory in which nodemon was started, and if they change, it will automatically restart your node...
Read more >
nodemon - npm
nodemon will watch the files in the directory that nodemon was started, and if they change, it will automatically restart your node ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found