注意事项
🌐 Caveats
fs.watch API 在各个平台上的表现并不完全一致,并且在某些情况下无法使用。
🌐 The fs.watch API is not 100% consistent across platforms, and is
unavailable in some situations.
在 Windows 上,如果被监视的目录被移动或重命名,将不会触发任何事件。删除被监视的目录时,会报告 EPERM 错误。
🌐 On Windows, no events will be emitted if the watched directory is moved or
renamed. An EPERM error is reported when the watched directory is deleted.
fs.watch API 不会对文件系统上的恶意操作提供任何保护。例如,在 Windows 上,它的实现方式是监视目录中的变化而不是具体文件。这允许替换文件,并且 fs 会对具有相同文件名的新文件报告变化。
🌐 The fs.watch API does not provide any protection with respect
to malicious actions on the file system. For example, on Windows it is
implemented by monitoring changes in a directory versus specific files. This
allows substitution of a file and fs reporting changes on the new file
with the same filename.