Skip to Content
APIrmdir

rmdir

Remove an empty directory. Fails if the directory is not empty; use rm with recursive: true for non-empty trees.

Basic usage

import { rmdir } from '@rush-fs/core' await rmdir('./empty-dir')

Methods

rmdir(path)

Async. Returns Promise<void>.

ArgumentTypeDescription
pathstringPath to the empty directory.

rmdirSync(path)

Sync. Same arguments; throws on error (e.g. ENOTEMPTY if not empty).

Performance

Single syscall; on par with Node.js. No dedicated benchmark; see Benchmarks for single-file overhead.

Notes

  • Non-empty: Use rm(path, { recursive: true }) to remove a directory and its contents.
  • Errors: Same as Node.js (e.g. ENOENT, ENOTEMPTY, EACCES).
Last updated on