fs.rmSync(path[, options])


  • path <string> | <Buffer> | <URL>
  • options <Object>
    • force <boolean>true 时,如果 path 不存在,异常将被忽略。默认值: false
    • maxRetries <integer> 如果遇到 EBUSYEMFILEENFILEENOTEMPTYEPERM 错误,Node.js 将重试该操作,每次重试的等待时间以线性方式增加 retryDelay 毫秒。此选项表示重试次数。如果 recursive 选项不是 true,此选项将被忽略。默认值: 0
    • recursive <boolean> 如果 true,执行递归目录删除。在递归模式下,操作失败时会重试。默认值: false
    • retryDelay <integer> 在重试之间等待的时间(毫秒)。如果 recursive 选项不是 true,则会忽略此选项。默认值: 100

同步删除文件和目录(仿照标准的 POSIX rm 工具)。返回 undefined

🌐 Synchronously removes files and directories (modeled on the standard POSIX rm utility). Returns undefined.