25 Nov 2013, 16:04
Richsmall2_pragsmall

Richard Lee (2 posts)

watcher-spawn.js doesn’t work for me.

I see:

D:\Projects\node-projects\file-system>node --harmony watcher-spawn.js target.txt
Now watching target.txt for changes...

…touch file here…

events.js:72
    throw er; // Unhandled 'error' event
          ^ Error: spawn ENOENT
at errnoException (child_process.js:980:11)
at Process.ChildProcess._handle.onexit (child_process.js:771:34)`

Using Windows 7, running “copy /b target.txt +,,” to touch the target file. node v0.10.22. Code is per the example in the book.

Any ideas? Thanks Rich

25 Nov 2013, 17:45
Avatar_pragsmall

Jim R. Wilson (60 posts)

Interesting! I wonder if this has to do with the way that the copy command works.

What happens if you use echo to append to the file instead?

echo.>> target.txt
26 Nov 2013, 10:18
Richsmall2_pragsmall

Richard Lee (2 posts)

Hi Jim, thanks for responding, (and thanks for the book btw)

I get the same error using echo, and if I make an edit to target.txt. The earlier examples work fine, and I double-checked using your own code.

I replaced the line with the pipe call with

console.log('made it here');

and when run the text is output before the error is thrown. I guess I’ll come back to this later wehn I have time to dig into the node docs and find out how to debug.

Cheers Rich

26 Nov 2013, 16:56
Avatar_pragsmall

Jim R. Wilson (60 posts)

Oh I see, I think I understand now. It’s probably the call to ls. Windows doesn’t have a program called ls and so it triggers the ENOENT error, which Node is bubbling up to you.

If you ran the watcher through a shell like Cygwin it might have access to ls. Alternatively, if you changed ls to dir with appropriate arguments, that might work too (dir isn’t going to recognize -h for example, since Windows command line arguments are prefixed with slashes, not dashes).

  You must be logged in to comment