File watcher package?


Is there’s a package which allows file watchers to be easily created?

For instance, I’d like to write a file watcher that detects a change to a LESS file and then runs a script to compile said less file (and others) to the target CSS output.

I realize this is frequently better to do at build-time (rather than at dev time) but I’m not able to make that change at this point to the package.


The ‘Markdown Preview’ package does that (watch for file changes), it uses pathwatcher


Awesome – thx @AbeEstrada


Hi, I’d like to ask if it’s better to use the pathwatcher package or the native of Node? Do you’ve any recommendations on that (wrt. performance, reliability, …)?



Thanks, that answers my question :slight_smile:


I’m using now the pathwatcher package in my project-view package and under Linux everything works as expected. But now I’ve noticed that the installation of my package fails now under Windows due to a node-gyp failure (see below).
Why doesn’t this error gets thrown when installing the tree-view on Windows? Could it be that with the Atom a pre-build version of this package gets shipped? If that’s the case and you need some Windows SDK installed in order to use my package then sadly I’ve to remove the pathwatcher again and replace it against the native Any advices?


> runas@3.1.1 install C:\Users\Subesokun\AppData\Local\Temp\apm-install-dir-1151113-6412-1joutzg\node_modules\project-view\node_modules\pathwatcher\node_modules\runas
> node-gyp rebuild

C:\Users\Subesokun\AppData\Local\Temp\apm-install-dir-1151113-6412-1joutzg\node_modules\project-view\node_modules\pathwatcher\node_modules\runas>if not defined npm_config_node_gyp (node "C:\Users\Subesokun\AppData\Local\atom\app-1.3.0-beta0\resources\app\apm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )

gypnpm ERR! Windows_NT 6.2.9200
npm ERR! argv "C:\\Users\\Subesokun\\AppData\\Local\\atom\\app-1.3.0-beta0\\resources\\app\\apm\\bin\\node.exe" "C:\\Users\\Subesokun\\AppData\\Local\\atom\\app-1.3.0-beta0\\resources\\app\\apm\\node_modules\\npm\\bin\\npm-cli.js" "--globalconfig" "C:\\Users\\Subesokun\\.atom\\.apm\\.apmrc" "--userconfig" "C:\\Users\\Subesokun\\.atom\\.apmrc" "install" "C:\\Users\\Subesokun\\AppData\\Local\\Temp\\d-1151113-6412-wlp93s\\package.tgz" "--target=0.34.3" "--arch=ia32"
npm ERR! node v0.10.40
npm ERR! npm  v2.13.3

npm ERR! runas@3.1.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the runas@3.1.1 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the runas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls runas
npm ERR! There is likely additional logging output above.


Ah. It’s runas again. I’ve had several npm modules fail with the runas error. I posted an issue on the runas site and I don’t think it has been resolved.


@mark_hahn Thanks for the feeback. To be on the safe side I’ve removed pathwatch and replaced it for the time being with


Sorry to open this up again, but I stepped into a similar issue with pathwatcher. I had a quick look in the Discussion pages, and I did not get very far.

Apparently, I can use pathwatcher within the Atom Dev console as other inbox modules:

var pw = require('pathwatcher');'/home/yolo/file', function(event, path) {
  // do the magic here, this actually works

I can also install patwatcher (version 6.5.0) with npm and everything runs smoothly.

I get trouble when I try to require it within an Atom package. Every time I include it, I get this silent and deadly

Cannot find module 'pathwatcher'

I’m running Atom version 1.5.4 from Arch Linux 4.3.3-3 (no success with the latest update, too many bugs, so I’ll stick with 1.5.4 for a while I guess).

Anyone had the same issues about pathwatcher? I’ll fix if by using the regular fs watcher, but it would be nice to use pathwatcher instead.

Cheers guys!