Node fs.unlink function | API Reference | Bun
BuildDocsReferenceGuidesBlogDiscord/
node:fs/
unlinkNunlink
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
node:fs/
unlinkNunlink
namespace
fs.unlink {
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 rmdir.
See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more details." data-algolia-static="false" data-algolia-merged="true" data-type="Namespace">function
unlink(path:
PathLike,callback:
NoParamCallback): void;
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 rmdir.
See the POSIX unlink(2) documentation for more details.
namespace
unlinkResources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →