注意事项
¥Caveats
fs.watch
API 跨平台并非 100% 一致,并且在某些情况下不可用。
¥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 上,它是通过监视目录中与特定文件中的更改来实现的。这允许替换文件并使用相同的文件名报告新文件的更改。
¥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.