rm
from node:fs/promises
. This is like running rm -rf
in JavaScript.
These options configure the deletion behavior:
recursive: true
- Delete subdirectories and their contentsforce: true
- Don’t throw errors if the directory doesn’t exist
force
to ensure the directory exists:
See Docs > API > FileSystem for more filesystem operations.