nodemon -v: 1.17.2node -v: 9.8.0It working
Not working
Simply try, maybe it only on Arch linux
Can you give us any more information other than "not working"? For example, what symptoms do you observe that indicate it is not working? Are there any error messages?
Not working restart via watching files. No error messages
Experiencing the same. nodemon process seems to go to 100% and doesn't restart after a file change, or sometimes does but only after an extremely long delay. (On OSX, node 8.9.4, nodemon 1.17.2). Reverting to 1.17.1 fixes the issue.
@gavinaiken are you working with typescript too or is this a simple hello world script ala require('http').createServer((req, res) => res.end('ok')).listen(8000)?
No, not working with typescript, just javascript. I'm using gulp-nodemon with a gulp task to re-run mocha tests. I've been using the same setup for a couple of years, it has always worked well until this version of nodemon. Here's the gulp task:
const nodemon = require('gulp-nodemon');
gulp.task('mocha-tdd', false, ['test-pre', 'build-modules'], function (cb) {
var exec = 'gulp mocha';
return nodemon({
watch: [ paths.moduleSrc, paths.testSrc ],
ignore: [ paths.web, paths.build ],
ext: 'js json yml',
exec: exec
});
});
It's watching a couple of thousand files, we have quite a big project across a bunch of modules.
Can you replicate with nodemon directly (by removing the nodemon-gulp?) Just to rule it out?
Also, I doubt if it's related, but I've released a small bug fix at 1.17.3
On 1.17.3 I have this blocker https://github.com/remy/nodemon/issues/1305
Yes I can reproduce it with just the nodemon command, along these lines:
node_modules/.bin/nodemon -w '../[a-zA-Z]*/src/**/*.js' -w '../[a-zA-Z]*/test/**/*.js' -i ../web-client -e js,json,yml -x 'gulp mocha'
I see the problem (using the above command) with 1.17.2 and 1.17.3 but not with 1.17.1
Trying to narrow down what change has caused the problem. Comparing versions https://github.com/remy/nodemon/compare/v1.17.1...v1.17.2 it seems most of the changes are in lib/monitor/watch.js, and if I copy that file from 1.17.1 and use it with 1.17.2 I do not observe the problem. So it's definitely one of the changes in there.
If I use DEBUG=nodemon:watch I can see that v1.17.2 is watching everything in my various node_modules directories, and 1.17.1 is not. So somehow it is interpreting the arguments differently. I am digging into it further...
Starting to get to the bottom of the issue. Looks like we have been using nodemon incorrectly for a long time, but it was working anyway, although not doing exactly what we thought it was doing. The recent change has broken that behaviour.
In more detail - we have always passed a glob pattern as the watch argument. Reading the README I see that it says not to do that, but to pass directories instead. i.e. we have been doing it wrong...
Our glob pattern is quite complex but I can reproduce the issue just with a simple glob pattern eg
DEBUG=nodemon* nodemon -w '../[A-Za-z]*/src' -e js,json,yml -x 'gulp mocha'
If I run that, I see a debug output line like this:
nodemon config: dirs [ '/Users/gavin/repos/node-core' ] +47ms
where /Users/gavin/repos/node-core is the absolute path equivalent of ../ - i.e. nodemon is just ignoring the [A-Za-z]*/src part of the glob pattern. Fair enough, the docs do say not to use globs!
The change in behaviour however seems to be that in 1.17.1 all the node_modules dirs under /Users/gavin/repos/node-core are ignored. (There are several of them, and lots of module dependencies.) In 1.17.2 and .3, it is watching files in the node_modules dirs. This is despite it outputting this debug:
nodemon ignored [ '**/.git/**',
'**/.nyc_output/**',
'**/.sass-cache/**',
'**/bower_components/**',
'**/coverage/**',
'**/node_modules/**',
which says it will be ignoring anything in those dirs. That seems to have been broken in 1.17.2.
So I need to expand my glob pattern before passing it in to nodemon as the watch args, which I think will resolve my issue, because I will then be watching subdirs with no node_modules. But it looks like there is a bug in the latest that needs resolving to make it honor the ignores properly.
I'm still trying to digest this detail, but for reference, the _main_ change in watch.js is this line:
cwd: process.cwd()
Which, as subtle as it looks, does have a fairly significant impact.
@gavinaiken are you able to replicate with a simpler project? I've got an issues repo that I test against which if I can replicate too, I should be able to fix (I've seen this similar issue in the past, and it's always down to the combination of watch/ignore and chokidar options).
Yes I just replicated with a very simple project. It seems that problem only shows up if you have nodemon watching a parent directory. We have a monorepo with lots of npm modules in a directory which is managed by git. With the glob problem I described above, we were watching the parent dir which contains all the modules (which is more or less what we want to do anyway), and when you do that it seems that nodemon 1.17.2 watches the contents of node_modules in all the other child dirs of the parent except the current dir. Here's a simple set of steps to demonstrate the issue:
mkdir nodemon-test
cd nodemon-test
mkdir nodemon-test-1.17.1
cd nodemon-test-1.17.1
touch index.js
npm init --yes
npm install [email protected]
cd ..
mkdir nodemon-test-1.17.2
cd nodemon-test-1.17.2
touch index.js
npm init --yes
npm install [email protected]
cd ../nodemon-test-1.17.1
DEBUG=nodemon* node_modules/.bin/nodemon -w .. --exec echo restart
cd ../nodemon-test-1.17.2
DEBUG=nodemon* node_modules/.bin/nodemon -w .. --exec echo restart
If you do those steps exactly you should see that the 1.17.1 outputs this debug:
nodemon:watch watching dir: nodemon-test-1.17.1/package.json +0ms
nodemon:watch watching dir: nodemon-test-1.17.1/index.js +0ms
nodemon:watch watching dir: nodemon-test-1.17.2/index.js +1ms
nodemon:watch watching dir: nodemon-test-1.17.2/package.json +0ms
whereas 1.17.2 outputs this:
nodemon:watch watching dir: ../nodemon-test-1.17.1/index.js +0ms
nodemon:watch watching dir: ../nodemon-test-1.17.1/package.json +0ms
nodemon:watch watching dir: index.js +0ms
nodemon:watch watching dir: package.json +0ms
nodemon:watch watching dir: ../nodemon-test-1.17.1/node_modules/abbrev/LICENSE +55ms
... very many lines for node_modules ...
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
I don't think this issue should be closed - I replicated the issue with a very simple set of commands (see my previous comment) so this should be easy to reproduce, and seems to me to be worth fixing.
@gavinaiken +1 - I was trying to replicate this morning, but real/paid work took a priority. I'll try to take another look again to work out what the right fix is.
Thanks for raising this issue, and hopefully you're happy with @remy's fix. If you'd like to support this project, you can do just that through the open collective https://opencollective.com/nodemon/donate or at the very least, starring this project would give me @remy a little smile 鉂わ笍
1.17.4 seems to work great to me, thanks for the fix! 馃憤