nodemon ignores changes in watched directories
See original GitHub issueHi! I’m working with a dead simple Express app in WSL 2 Ubuntu. Project resides on a mounted NTFS partition and its structure is the following:
app.js
models
|__author.js
|__book.js
node_modules
|__...
nodemon.json
package-lock.json
package.json
schema
|__schema.js
Now I cannot for the life of me figure out how to make Nodemon restart the server upon changes to files under ‘models’ and ‘schema’ directories. It is only triggered by changes in files that are in the root folder like app.js and nodemon.json. The nodemon.json is only 3 LOC:
{
"watch": [ "schema", "models", "./" ]
}
Before that I tried nodemon --watch schema/ --watch models --watch . app. No luck. Seems like a bug to me.
- Operating system/terminal environment: WSL2 Ubuntu on Win10 19042.572
- Using Docker? No
- Command you ran:
nodemon app
Here is the output of nodemon --dump:
[33m[nodemon] 2.0.6[39m
[33m[nodemon] to restart at any time, enter `rs`[39m
[33m[nodemon] watching path(s): schema/**/* models/**/* **/*[39m
[33m[nodemon] watching extensions: js,mjs,json[39m
--------------
node: v15.0.1
nodemon: 2.0.6
command: /home/<me>/.nvm/versions/node/v15.0.1/bin/node /home/<me>/.nvm/versions/node/v15.0.1/bin/nodemon --dump
cwd: /mnt/e/dev/graphql_exercise/server
OS: linux x64
--------------
{
run: false,
system: { cwd: '/mnt/e/dev/graphql_exercise/server' },
required: false,
dirs: [
'/mnt/e/dev/graphql_exercise/server/schema',
'/mnt/e/dev/graphql_exercise/server/models',
'/mnt/e/dev/graphql_exercise/server'
],
timeout: 1000,
options: {
dump: true,
watch: [ 'schema', 'models', './', re: /schema|models|\.\// ],
ignore: [
'**/.git/**',
'**/.nyc_output/**',
'**/.sass-cache/**',
'**/bower_components/**',
'**/coverage/**',
'**/node_modules/**',
re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/
],
monitor: [
'/mnt/e/dev/graphql_exercise/server/schema/**/*',
'/mnt/e/dev/graphql_exercise/server/models/**/*',
'/mnt/e/dev/graphql_exercise/server/**/*',
'!**/.git/**',
'!**/.nyc_output/**',
'!**/.sass-cache/**',
'!**/bower_components/**',
'!**/coverage/**',
'!**/node_modules/**'
],
ignoreRoot: [
'**/.git/**',
'**/.nyc_output/**',
'**/.sass-cache/**',
'**/bower_components/**',
'**/coverage/**',
'**/node_modules/**'
],
restartable: 'rs',
colours: true,
execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' },
stdin: true,
runOnChangeOnly: false,
verbose: false,
signal: 'SIGUSR2',
stdout: true,
watchOptions: {},
execOptions: {
script: 'index.js',
exec: 'node',
args: [],
scriptPosition: 0,
nodeArgs: undefined,
execArgs: [],
ext: 'js,mjs,json',
env: {}
}
},
load: [Function (anonymous)],
reset: [Function: reset],
lastStarted: 0,
loaded: [ '/mnt/e/dev/graphql_exercise/server/nodemon.json' ],
watchInterval: null,
signal: 'SIGUSR2',
command: {
raw: { executable: 'node', args: [ 'index.js' ] },
string: 'node index.js'
}
}
--------------
Expected behaviour
Server restart on changes in files in root folder as well as “schema” and “models” directories.
Actual behaviour
Nodemon ignores changes to files in some directories and triggered by changes to those directly in the root folder.
Steps to reproduce
Specify watch directories either via command line arguments or in nodemon.json.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8

Top Related StackOverflow Question
In the wake of that previous comment I looked for the issue on wsl and it turns out that the project needs to reside on the linux root file system in case of wsl2. now that i moved the project from ‘/mnt/e/…’ to ‘/home/…’, Nodemon is working as expected.
Automatically closing this issue due to lack of activity