Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filesystem watcher using node.js

Tags:

node.js

I want to implement file system watcher using node.js so that it watches a particular directory for any files being added/deleted. Can somebody give an idea how to implement this?

Thanks

like image 734
Ajay Avatar asked Dec 04 '22 20:12

Ajay


2 Answers

check out fs.watchFile(filename, [options], listener) for the inbuilt file system watching

like image 57
fbstj Avatar answered Dec 26 '22 16:12

fbstj


The core node.js watching will trigger a change event on the parent directory when a file is deleted, among other oddities. You can use Watchr to get useful events, and watching directory trees.

like image 31
balupton Avatar answered Dec 26 '22 14:12

balupton