fsPromises.rmdir(path[, options])


  • path <string> | <Buffer> | <URL>

  • options <Object> 目前没有公开任何选项。recursivemaxBusyTriesemfileWait 过去曾有选项,但它们已被弃用并移除。为了向后兼容,options 参数仍然被接受,但已不再使用。

    ¥options <Object> There are currently no options exposed. There used to be options for recursive, maxBusyTries, and emfileWait but they were deprecated and removed. The options argument is still accepted for backwards compatibility but it is not used.

  • 返回:<Promise> 成功时将使用 undefined 履行。

    ¥Returns: <Promise> Fulfills with undefined upon success.

删除由 path 标识的目录。

¥Removes the directory identified by path.

在文件(而不是目录)上使用 fsPromises.rmdir() 会导致 promise 被拒绝,在 Windows 上使用 ENOENT 错误,在 POSIX 上使用 ENOTDIR 错误。

¥Using fsPromises.rmdir() on a file (not a directory) results in the promise being rejected with an ENOENT error on Windows and an ENOTDIR error on POSIX.

要获得类似于 rm -rf Unix 命令的行为,则使用具有选项 { recursive: true, force: true }fsPromises.rm()

¥To get a behavior similar to the rm -rf Unix command, use fsPromises.rm() with options { recursive: true, force: true }.