Skip to Content
APIunlink

unlink

Remove a file. Fails for directories; use rm with recursive: true for directories.

Basic usage

import { unlink } from '@rush-fs/core' await unlink('./temp.txt')

Methods

unlink(path)

Async. Returns Promise<void>.

ArgumentTypeDescription
pathstringFile path to remove.

unlinkSync(path)

Sync. Same arguments; throws on error (e.g. ENOENT, EISDIR).

Performance

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

Notes

  • Directories: Use rm(path, { recursive: true }) or rmdir(path) for empty dirs. unlink on a directory fails with EISDIR (or equivalent).
Last updated on