问题
I am looking at the docs for fs.watch
https://nodejs.org/docs/latest/api/fs.html#fs_fs_watch_filename_options_listener
How can I watch all files in the current directory, but ignore node_modules?
回答1:
Doesn't look like it's possible. Just take a look at the path in the listener and do nothing if it starts with 'node_modules'.
It can't be that much of a performance hit, unless you're constantly updating modules while node is running, which would be a little strange.
来源:https://stackoverflow.com/questions/48054139/use-fs-watch-but-ignore-node-modules