Evaluate the applicable retention policy before calling any filesystem removal API. In Node.js 24, unlink removes one file or symbolic link, while rm can remove a file or directory; neither chooses a retention period, confirms legal compliance, or records policy approval for your application.
Run the retention decision before filesystem deletion
Treat eligibility and removal as separate steps: the policy decision authorizes or blocks deletion; Node.js performs the authorized filesystem operation. The Node.js v24.20.0 File system API documentation describes removal mechanics, not campaign-retention rules.
As an Amazon Associate I earn from qualifying purchases.
- Load the asset record. Retrieve the campaign image or video record and the metadata your organization’s authoritative retention policy needs.
- Evaluate the applicable rule. Check the policy and any relevant hold or approval state. The fields, rules, and values are application-specific; Node.js does not define them.
- Stop unless deletion is affirmatively allowed. If the decision blocks deletion, or cannot establish permission, do not call
unlinkorrm. Record the decision and reason in your application’s audit mechanism. - Resolve and constrain the target. Obtain the intended path from trusted asset metadata. Match the operation and scope to what the policy decision authorizes; do not broaden a single-asset decision into recursive directory deletion.
- Perform the authorized operation and handle its result. Await the filesystem call, handle errors, and record the deletion result in your application’s audit mechanism. The Node.js API reference does not promise to create an audit trail.
Choose unlink or rm by target and scope
| API | Target it removes | Scope and relevant behavior |
|---|---|---|
unlink / fsPromises.unlink() |
A file or symbolic link | Does not remove a directory, whether empty or not. Use for an individual file or symbolic link. |
rm / fsPromises.rm(path, options) |
Files and directories | Use for an individual target or, with recursive: true, an explicitly authorized directory tree. Recursion is off by default. |
The v24.20.0 documentation describes fsPromises.rm as removing “files and directories (modeled on the standard POSIX rm utility).” For recursive directory removal, use rm; recursive fs.rmdir behavior is deprecated.
Use rm options deliberately
In the Node.js v24.20.0 API, fsPromises.rm(path, options) fulfills with undefined on success. Its documented defaults are conservative: it does not recursively remove directories, suppress missing-path errors, or retry by default.
#1 Best Overall
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
| Option | Documented default | Effect and decision |
|---|---|---|
recursive |
false |
Set to true only when the authorized target is a directory tree that should be removed recursively. |
force |
false |
When enabled, suppresses errors for a missing path. Decide explicitly whether a missing target counts as success in your workflow. |
maxRetries |
0 |
Maximum retries for documented retryable errors in recursive mode. Retries do not make deletion eligible. |
retryDelay |
100 ms |
Delay between retries in recursive mode. Choose retry behavior for operational needs, not as a retention control. |
When retries are configured for recursive removal, the documentation lists EBUSY, EMFILE, ENFILE, ENOTEMPTY, and EPERM as retryable error classes. Retry settings apply only when recursive is true.
Illustrative Node.js 24 implementation
This example shows the sequence, not a ready-made policy or complete production implementation. The policy evaluator, asset model, path authorization, error handling, and audit storage must be supplied by the application.
Rank #2
- Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
import { rm, unlink } from 'node:fs/promises';
async function deleteEligibleAsset(asset, policy, { directory = false } = {}) {
// Implement this check from the organization's authoritative retention policy.
// It must account for applicable holds and approvals before any removal call.
const decision = await policy.evaluate(asset);
if (!decision.allowed) {
return { deleted: false, reason: decision.reason };
}
// Choose only the scope authorized by the policy decision.
if (directory) {
await rm(asset.path, { recursive: true });
} else {
await unlink(asset.path);
}
return { deleted: true };
}
For a production job, ensure the policy decision authorizes the actual path and scope being removed, and add application-level logging for both blocked decisions and filesystem outcomes. If the job needs to tolerate a missing path or retry transient failures, configure those behaviors explicitly; neither force: true nor recursive deletion replaces the retention gate.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsQuick Recap
Best Value
- [Upgraded Version] - This external hard drive features a mirrored logo stripe combined with a striped anti-slip design, and the rounded corners of the casing make it easier to grip. The stripes also have a heat dissipation function, ensuring stable and fast data transfer.
- 【Ultra-thin and quiet】 - The motherboard adopts JMicron 578 noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
- 【Ultra-Fast Data Transfers】 - Pairing this external hard drive with JMicron 578 solution USB 3.0 and USB 2.0 interfaces enables blazing-fast data transfer. It boasts theoretical read speeds of up to 125MB/s and write speeds of up to 103MB/s.
- 【Plug and Play】 - With no software to install, just plug it in and the drive is ready to use.The hard disk chip is wrapped with an aluminum anti-interference layer to increase heat dissipation and protect data.
- 【What You Get】 - 1 x Portable Hard Drive, 1 x USB 3.0 Cable, 1 x User Manual, Gift-type shell packaging ,Three-year manufacturer's warranty and free technical support services.
Rank #4
- Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Rank #3
- Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




