# fs-extra — card for AI agents

Extends Node.js fs with recursive mkdir, copy and remove methods.

Category: Utilities · npm package `fs-extra` · latest version 11.4.1 (checked 2026-11-01)
Install: `npm install fs-extra`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Numbers (AgentGid data)
- Gid Score: 72.3 (#298 of all tools, 30 of 408 in its category)
- Used in 64 public projects set up for AI coding agents (1.0%)
- Downloads last week: 313,721,074 (as of 2026-11-24), +38.1% over 4 weeks
- GitHub stars: 9,594 (as of 2026-11-24)
- Last push: 2026-11-11

## Often used with
chalk 39.1%, Vitest 53.1%, tsx 42.2%, glob 28.1%, uuid 28.1%, TypeScript 79.7%

## Links
- AgentGid page: https://agentgid.com/tools/fs-extra/
- Homepage: https://github.com/jprichardson/node-fs-extra
- Repository: https://github.com/jprichardson/node-fs-extra


## fs-extra: copy, move and clean folders in Node.js

fs-extra is a free library for Node.js programs that work with files. It adds the everyday steps the built-in file module lacks, such as copying a whole folder, making nested folders, deleting a folder with everything in it, and saving settings files. You use it in place of the built-in module, so existing code keeps working.

### Where to use it
- Start a project from a template folder: Your setup script copies a starter folder with all its subfolders into a new project, skipping files you do not want.
- Save settings into a new folder: Your app writes a settings or results file into a folder that may not exist yet; the folder is created on the way.
- Clear the build folder before a build: Before each build your script empties the output folder but keeps the folder itself, so old files never ship by mistake.
- Move finished uploads to storage: After an upload is checked, your server moves the file from a temporary folder to its final place, even on another disk.
- Delete temporary work folders: Your tool removes its scratch folder with everything inside when a job ends, and does not fail if it is already gone.
- Write files an AI agent generates: Your agent writes many generated files into new nested folders; one call per file creates the folders and saves the text. (idea, not from the official pages)

### How to start
- Add fs-extra to your Node.js project.

```
npm install fs-extra
```

- Load it instead of the built-in fs; every method returns a promise when you pass no callback.

```
const fs = require('fs-extra')
```

- In an ES module project, import the extra methods from fs-extra/esm, or import the default from fs-extra.

```
import { readFileSync } from 'fs'
import { readFile } from 'fs/promises'
import { outputFile, outputFileSync } from 'fs-extra/esm'
```


### License
Free to use, also in paid and closed-source products, under the MIT license. Keep the copyright and license notice when you pass its files on.

### Good to know
- It needs Node.js 14.14 or newer and runs only in Node.js, not in a web page.
- Copying a folder copies what is inside it, not the folder itself: copying "photos" into "backup" puts the photos straight into "backup".
- With overwrite turned off, a copy onto an existing file silently does nothing unless you also ask for an error.
- It has no file watching; the README sends you to chokidar for that.
- Newer Node.js versions can copy whole folders on their own (fs.cp), so a small script may not need fs-extra.

Checked 2026-11-11 against: https://github.com/jprichardson/node-fs-extra/blob/master/README.md, https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md, https://github.com/jprichardson/node-fs-extra/blob/master/LICENSE, https://github.com/jprichardson/node-fs-extra/blob/master/docs/copy.md, https://github.com/jprichardson/node-fs-extra/blob/master/docs/emptyDir.md, https://github.com/jprichardson/node-fs-extra/blob/master/docs/ensureDir.md, https://github.com/jprichardson/node-fs-extra/blob/master/docs/move.md, https://github.com/jprichardson/node-fs-extra/blob/master/docs/outputFile.md, https://github.com/jprichardson/node-fs-extra/blob/master/docs/outputJson.md, https://github.com/jprichardson/node-fs-extra/blob/master/docs/remove.md, https://github.com/jprichardson/node-fs-extra/blob/master/docs/readJson.md, https://registry.npmjs.org/fs-extra, https://registry.npmjs.org/fs-extra/latest, https://nodejs.org/api/fs.html

### Mistakes to avoid
- Don't: import { readFileSync, copy } from 'fs-extra/esm' → Do: Import fs methods from 'fs' or 'fs/promises', and only the extra methods (copy, outputFile, ...) from 'fs-extra/esm'; or use import fs from 'fs-extra' (The fs-extra/esm entry does not carry the built-in fs methods.)
- Don't: require('fs-extra/lib/copy') → Do: require('fs-extra') and call fs.copy(...) (Since version 11 the package only exposes its main entry and fs-extra/esm; deep paths throw.)
- Don't: fs.copy(src, dest, { overwrite: false }) and assuming an existing file means an error → Do: { overwrite: false, errorOnExist: true } when you need to know the copy was skipped (With overwrite off and the target present, the copy silently does nothing.)
- Don't: fs.copy('photos', 'backup') expecting backup/photos → Do: fs.copy('photos', 'backup/photos') (Copying a folder copies its contents into the destination, not the folder itself.)
- Don't: fs.access(file, fs.F_OK) on Node.js 24 → Do: fs.access(file, fs.constants.F_OK) (The old top-level constants are not exported on Node.js 24 and newer.)

### Questions
- Do I still need the built-in fs module? No. All fs methods are attached to fs-extra, so one import covers both, except in the fs-extra/esm entry.
- Does it work with async and await? Yes. Async methods return a promise when you pass no callback; the sync versions throw on errors.
- Can it watch a folder for changes? No. The README recommends chokidar for watching files and folders.
- Where did walk() go? It was removed in version 2.0.0; the README points to the separate klaw and klaw-sync packages.
- Are there TypeScript types? Not in the package; the README points to the community types on DefinitelyTyped (@types/fs-extra).

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
