使用fs.watch但忽略node_modules [英] Use fs.watch but ignore node_modules

查看:118
本文介绍了使用fs.watch但忽略node_modules的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看fs.watch的文档

I am looking at the docs for fs.watch

https://nodejs.org/docs/latest/api/fs .html#fs_fs_watch_filename_options_listener

如何查看当前目录中的所有文件,但忽略node_modules?

How can I watch all files in the current directory, but ignore node_modules?

推荐答案

看起来不可能.只需看看侦听器中的路径,如果它以'node_modules'开头就什么也不做.

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.

这篇关于使用fs.watch但忽略node_modules的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆