fsPromises.rm(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
  • 返回:<Promise> 成功时返回 undefined

删除文件和目录(基于标准 POSIX rm 工具)。

【Removes files and directories (modeled on the standard POSIX rm utility).】