fs.unwatchFile(filename[, listener])


停止监视 filename 的更改。如果指定了 listener,则只会移除该特定监听器。否则,将移除所有监听器,从而有效地停止对 filename 的监视。

🌐 Stop watching for changes on filename. If listener is specified, only that particular listener is removed. Otherwise, all listeners are removed, effectively stopping watching of filename.

对未被监听的文件名调用 fs.unwatchFile() 不会有任何操作,也不会报错。

🌐 Calling fs.unwatchFile() with a filename that is not being watched is a no-op, not an error.

使用 fs.watch()fs.watchFile()fs.unwatchFile() 更高效。在可能的情况下,应使用 fs.watch() 替代 fs.watchFile()fs.unwatchFile()

🌐 Using fs.watch() is more efficient than fs.watchFile() and fs.unwatchFile(). fs.watch() should be used instead of fs.watchFile() and fs.unwatchFile() when possible.