Nodemon: Nodemon does not restart the server on files changes

Created on 5 Jan 2014  ·  32Comments  ·  Source: remy/nodemon

Updated to v1.0.1 and then to v1.0.4 and I can't get the server restarted on file changes.

C:\wamp\www\DoLyfe>nodemon -V --dump server.js
5 Jan 20:56:41 - [nodemon] v1.0.4
5 Jan 20:56:41 - [nodemon] to restart at any time, enter `rs`
5 Jan 20:56:41 - [nodemon] ignoring: .git/* node_modules/**/node_modules/*
5 Jan 20:56:41 - [nodemon] watching: *.*
5 Jan 20:56:41 - [nodemon] watching extensions: js
--------------
{ run: false,
  system: { noWatch: false, watchWorks: false },
  required: false,
  dirs: [ 'C:\\wamp\\www\\DoLyfe' ],
  timeout: 1000,
  options:
   { verbose: true,
     dump: true,
     script: 'server.js',
     args: [],
     ignore:
      [ '.git/',
        'node_modules/**/node_modules/',
        re: /\.git/|node_modules/.*.*/node_modules// ],
     watch: [ '*.*', re: /.*\..*/ ],
     restartable: 'rs',
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     execOptions:
      { script: 'server.js',
        exec: 'node',
        nodeArgs: undefined,
        ext: 'js',
        execArgs: [] },
     ext: 'js',
     monitor: [ '*.*', '!.git/*', '!node_modules/**/node_modules/*' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [] }
--------------
OS: win32 x64
node: v0.10.22
nodemon: v1.0.4
cwd: C:\wamp\www\DoLyfe
command: node C:\Users\Alex\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js -V --dump server
.js
--------------
5 Jan 20:56:41 - [nodemon] exiting

I'm changing and saving server.js and other js files in subfolders and nothing happens (server is not restarted, tested with actual page output as well).

bug windows

Most helpful comment

http://www.reactiongifs.us/wp-content/uploads/2013/03/nevermind_nathan_fillion.gif

All 32 comments

Confirmed.

Crap. On it.

Got a fix in the works, just running tests across all platforms (which hopefully will be fine!)

Fixed and in npm under [email protected]

Updated to v1.0.5, but it still doesn't work:

C:\wamp\www\DoLyfe>nodemon -V --dump server.js
6 Jan 00:34:03 - [nodemon] v1.0.5
6 Jan 00:34:03 - [nodemon] to restart at any time, enter `rs`
6 Jan 00:34:03 - [nodemon] ignoring: .git/* node_modules/**/node_modules/*
6 Jan 00:34:03 - [nodemon] watching: *.*
6 Jan 00:34:03 - [nodemon] watching extensions: js
--------------
{ run: false,
  system: { noWatch: false, watchWorks: false },
  required: false,
  dirs: [ 'C:\\wamp\\www\\DoLyfe' ],
  timeout: 1000,
  options:
   { verbose: true,
     dump: true,
     script: 'server.js',
     args: [],
     ignore:
      [ '.git/',
        'node_modules/**/node_modules/',
        re: /\.git/|node_modules/.*.*/node_modules// ],
     watch: [ '*.*', re: /.*\..*/ ],
     restartable: 'rs',
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     execOptions:
      { script: 'server.js',
        exec: 'node',
        nodeArgs: undefined,
        ext: 'js',
        execArgs: [] },
     ext: 'js',
     monitor: [ '*.*', '!.git/*', '!node_modules/**/node_modules/*' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [] }
--------------
OS: win32 x64
node: v0.10.22
nodemon: v1.0.5
cwd: C:\wamp\www\DoLyfe
command: node C:\Users\Alex\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js -V --dump server
.js
--------------
6 Jan 00:34:03 - [nodemon] exiting

Note: My command line is:

nodemon -V server.js

And the file is located in the folder this command is entered.

http://www.reactiongifs.us/wp-content/uploads/2013/03/nevermind_nathan_fillion.gif

Okay, so I can see from your config that the watchWorks: false - when it should be true...that's what's causing this problem.

What Windows OS are you on? (I tested on XP...probably a little low!) and what version of node (I tested v0.10.23).

Could you also try this and send me the output:

var fs = require('fs'),
    crypto = require('crypto'),
    file = 'test' + crypto.randomBytes(16).toString('hex');

console.log('watching', file);

fs.writeFileSync(file, 'ok');

setTimeout(function () {
  fs.watch(file, { persistent: false }, function (event, filename) {
    console.log('fs.watch worked', filename);
  });
}, 1000);

fs.watchFile(file, function (a, b) {
  console.log('watchFile worked');
})

setTimeout(function () {
  fs.writeFileSync(file, 'ok1');
}, 2000);

Not with nodemon, just running as "node script.js".

Hi,

I also face this problem. I use Windows 8.1 (x64), Node 0.10.24.

The output of this command for me is the following:

>node test.js
watching test5aa09b09f6618bf5fd3c3d53fba9bd1f
fs.watch worked test5aa09b09f6618bf5fd3c3d53fba9bd1f
fs.watch worked test5aa09b09f6618bf5fd3c3d53fba9bd1f
watchFile worked

If I open the generated file and add something to it, then I get the same messages again.

Thanks!

Can you also include the output of nodemon --dump so I can check your
config.

On Sunday, January 5, 2014, gaborpro wrote:

Hi,

I also face this problem. I use Windows 8.1 (x64), Node 0.10.24.

The output of this command for me is the following:

node test.js
watching test5aa09b09f6618bf5fd3c3d53fba9bd1f
fs.watch worked test5aa09b09f6618bf5fd3c3d53fba9bd1f
fs.watch worked test5aa09b09f6618bf5fd3c3d53fba9bd1f
watchFile worked

If I open the generated file and add something to it, then I get the same
messages again.

Thanks!


Reply to this email directly or view it on GitHubhttps://github.com/remy/nodemon/issues/252#issuecomment-31619873
.

— Remy

I am working now, sadly don't have access to my home machine. In the evening I can check it.

If it helps, I use the default config file which comes with npm.

@remy lol, the gif was funny! :-)

I'm on Win 8 x64, tried with Node v0.10.22 and updated to v0.10.24 as well (btw the node version is in the --dump output).

Here's the output of your script:

watching test808f642ac04ce787747d5dd5f0581f2a
fs.watch worked test808f642ac04ce787747d5dd5f0581f2a
fs.watch worked test808f642ac04ce787747d5dd5f0581f2a
watchFile worked

--dump output with Node v0.10.24:

C:\wamp\www\DoLyfe>nodemon -V --dump server.js
6 Jan 14:54:38 - [nodemon] v1.0.5
6 Jan 14:54:38 - [nodemon] to restart at any time, enter `rs`
6 Jan 14:54:38 - [nodemon] ignoring: .git/* node_modules/**/node_modules/*
6 Jan 14:54:38 - [nodemon] watching: *.*
6 Jan 14:54:38 - [nodemon] watching extensions: js
--------------
{ run: false,
  system: { noWatch: false, watchWorks: false },
  required: false,
  dirs: [ 'C:\\wamp\\www\\DoLyfe' ],
  timeout: 1000,
  options:
   { verbose: true,
     dump: true,
     script: 'server.js',
     args: [],
     ignore:
      [ '.git/',
        'node_modules/**/node_modules/',
        re: /\.git/|node_modules/.*.*/node_modules// ],
     watch: [ '*.*', re: /.*\..*/ ],
     restartable: 'rs',
     execMap: { py: 'python', rb: 'ruby' },
     stdin: true,
     execOptions:
      { script: 'server.js',
        exec: 'node',
        nodeArgs: undefined,
        ext: 'js',
        execArgs: [] },
     ext: 'js',
     monitor: [ '*.*', '!.git/*', '!node_modules/**/node_modules/*' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [] }
--------------
OS: win32 x64
node: v0.10.24
nodemon: v1.0.5
cwd: C:\wamp\www\DoLyfe
command: node C:\Users\Alex\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js -V --dump server
.js
--------------
6 Jan 14:54:38 - [nodemon] exiting

@alexilyaev that's great - cheers for the detail (and yep, I forgot that node version was in the dump!).

It's weird because the simple test worked for you (to check watch support), yet the system.watchWorks config setting is false.

Would you be able to join me in the #nodemon irc channel on freenode.net? I'd like to try out a few scripts to try to test and fix what's going on.

I've just fired up my Windows 8 VM, and that's saying it's got system.watchWorks = true too - so this is weird.

(and now I've just revived my windows laptop, and _even_ that is showing true for watchWorks, but clearly it's not flying for a few of you, so I'd like to sort it for you!).

I have the same problem, i'll be glad to help if you need to try something

Release going up shortly.

Fixed confirmed using this script: https://gist.github.com/remy/8283715

Confirmed with 1.0.6.
Thanks!

Just a question, doing Git pull trigger these lines with -V cmd.

6 Jan 20:59:36 - [nodemon] files triggering change check: .git
6 Jan 20:59:36 - [nodemon] changes after filters (before/after): 1/0
6 Jan 20:59:36 - [nodemon] files triggering change check: .git
6 Jan 20:59:36 - [nodemon] changes after filters (before/after): 1/0

They don't trigger a restart, but I'm wondering why they are being ran if .git is part of the ignore list?

{
    "ext": "js json",
    "ignore": [
        ".git",
        "app",
        "config",
        "logs",
        "node_modules",
        "scripts",
        "test"
    ]
}

Same thing for html files that are directly located under an ignored folder (e.g. app\index.html), though not in deeper levels.

And another quick one, can I tell Nodemon to monitor only 1 or more files (e.g. server.js) in the directory it's being ran?
So I won't have to ignore every folder in that root directory or put server.js in a sub-directory?

On .git being listed in the trigger check - you're right, it should be ignored altogether based on what you've got in your ignore. It's somehow getting through the check (I'll test again this week and see if there's something I can do to suppress it.

If you want it only restart on a single file (server.js I think that's what you're saying), then just put that in the watch:

{
  "watch": ["server.js"]
}

Now nodemon will only restart if server.js changes.

Great, that worked.
Then again, every other file saves trigger those change check lines, even though it should listen to only one file.

Looking at watch.js, I suppose the ignoredFilter function should be called before calling filterAndRestart, which is where these lines are being outputted.

Thank you!

@remy Btw, what was the difference between you're Win 8 VM and our setups?

Meaning, why did it work for you in your tests but didn't work for us?

I don't really know what the difference in the setup is (maybe because the
file system on my VM is sitting on a Mac OS and the file system is somehow
different, I don't know), but what I see from the --dump is that the
config.system.watchWorks is false, whereas mine was true.

But when I tested this evening, watchWorks was coming up as false, which is
why I was able to test this fix fully because I was able to replicate the
issue properly.

On 7 January 2014 22:18, Alex Ilyaev [email protected] wrote:

@remy https://github.com/remy Btw, what was the difference between
you're Win 8 VM and our setups?

Meaning, why did it work for you in your tests but didn't work for us?


Reply to this email directly or view it on GitHubhttps://github.com/remy/nodemon/issues/252#issuecomment-31786025
.

Hi @remy, I'm working on an API REST with typescript and I use nodemon to reload my server on each change. It works perfectly on unix systems but other collaborators have windows and it doesn't work. Do you have any idea what's going on?

Thank you.

Not with the information you've offered. Maybe get them using the windows
bash platform.

On Fri, 18 Nov 2016, 22:26 raansilrey, [email protected] wrote:

Hi @remy https://github.com/remy, I'm working on an API REST with
typescript and I use nodemon to reload my server on each change. It works
perfectly on unix systems but other collaborators have windows and it
doesn't work. Do you have any idea what's going on?

Thank you.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/remy/nodemon/issues/252#issuecomment-261658459, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAA1hK1SUmJVf-J4wZTgVLBEz1cc_Yz5ks5q_iYEgaJpZM4BXgow
.

I had a similar problem. I am running windows 10 and nodemon would not restart my web service when I made changes to the code. For whatever reason, node was installed in C:\Program Files (x86). Whenever, I would try to make an update, it complained I needed Administrative Privileges. I finally just moved the nodejs directory to the root of my c;\ drive. Everything works fine now whether using CMD line or PowerShell

Same issue. Linux Mint 18, 64bit. Was trying to run a tiddlywiki server. Here is the Nodemon dump

[nodemon]

1.11.0
[nodemon] to restart at any time, enter rs

[nodemon] watching: .

node: v6.9.1
nodemon: 1.11.0
command: /home/who/.nvm/versions/node/v6.9.1/bin/node /home/who/.nvm/versions/node/v6.9.1/bin/nodemon --dump
cwd: /home/who/yaah/Ildy

OS: linux x64

{ run: false,
system: { cwd: '/home/who/yaah/Ildy' },
required: false,
dirs: [ '/home/who/yaah/Ildy' ],
timeout: 1000,
options:
{ dump: true,
ignore:
[ '.git',
'.nyc_output',
'.sass-cache',
'bower_components',
'coverage',
'node_modules',
re: /.git|.nyc_output|.sass-cache|bower_components|coverage|node_modules/ ],
watch: [ '.', re: /.../ ],
ignoreRoot:
[ '.git',
'.nyc_output',
'.sass-cache',
'bower_components',
'coverage',
'node_modules' ],
restartable: 'rs',
colours: true,
execMap: { py: 'python', rb: 'ruby' },
stdin: true,
runOnChangeOnly: false,
verbose: false,
stdout: true,
execOptions:
{ script: null,
exec: 'node',
args: [],
scriptPosition: null,
nodeArgs: undefined,
ext: 'js,json',
env: {},
execArgs: [] },
monitor:
[ '.',
'!.git',
'!.nyc_output',
'!.sass-cache',
'!bower_components',
'!coverage',
'!node_modules' ] },
signal: 'SIGUSR2',
load: [Function],
reset: [Function: reset],
lastStarted: 0,
loaded: [],
watchInterval: null,

command: { raw: { executable: 'node', args: [] }, string: 'node' } }

For info; I had the same problem today with nodemon 1.11.0 and Node v7.10.0 . Fixed it by removing a .build folder in my root dir. The .build directory contained a babel-transpiled version of my source code tree. Once removed, everything was working fine again.

Had the same issue, but I guess what caused it was, the script parent folder had a . (dot) prefix.
Haven't dig deeper on why nodemon doesn't restart when the parent folder had a . in the folder name.
I removed the . prefix and everything worked again.

Using the -L (legacy option) worked for me in vagrant
Without it, it doesn't work

@iemadk Thank you for this, it was driving me crazy!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

piton13 picture piton13  ·  3Comments

jonerer picture jonerer  ·  4Comments

hkeio picture hkeio  ·  3Comments

Exeteres picture Exeteres  ·  4Comments

Bastorx picture Bastorx  ·  5Comments