unlink

external fun unlink(path: PathLike, callback: NoParamCallback)(source)

Asynchronously removes a file or symbolic link. No arguments other than a possible exception are given to the completion callback.

import { unlink } from 'node:fs';
// Assuming that 'path/file.txt' is a regular file.
unlink('path/file.txt', (err) => {
if (err) throw err;
console.log('path/file.txt was deleted');
});

fs.unlink() will not work on a directory, empty or otherwise. To remove a directory, use {@link rmdir}.

See the POSIX unlink(2) documentation for more details.

Since

v0.0.2


suspend fun unlink(path: PathLike): Void(source)