0

I'm working on an application that relies heavily on nodejs' filewatchers.

Now we found that IntelliJ's auto-save feature that writes to a file as you type / blur the window doesn't trigger nodejs filewatchers - at least not on mac.

The following simple test verifies this.

  • Create a file called file.txt
  • Create the following script in the same folder
  • Edit file.txt in IntelliJ or Webstorm
  • Nothing should be looked (where as if you edit the file in any other editor and save it you see change 0, change 1 etc.)

fs = require( "fs" );
i = 0;

fs.watch( "./file.txt", function(){
    i++;
    console.log( "change " + i );
});

Is there any workaround / way to make this work?

2 Answers 2

0

The simplest way:

  1. Right-click your script and choose Run <my script>.js
  2. Edit your txt file and then hit Ctrl+S
  3. See the result in Run Tool window
3
  • That works for the very first change, but subsequent changes don't trigger the filewatcher anymore Jun 6, 2013 at 11:34
  • works for me - all changes trigger the watcher (if I keep it running, of course)
    – lena
    Jun 6, 2013 at 13:47
  • Hm. On mac or windows? This seems to be a mac only problem. Also are you using IntelliJ or Webstorm? Jun 6, 2013 at 20:28
0

I believe the problem is with the safe write functionnality. I had the same problem and disabling it solved it. You'll find it in Settings / System Settingsenter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .