Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

fs-extra

Copy, move and clean folders in Node.js.

UtilitiesNPM

GitHubWebsite

1. License

“to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”

MIT allows use in paid and closed-source products.

github.com/jprichardson/node-fs-extra/blob/master/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 11, 2026. Tap a verdict to see its source.How we checkedReport an error

What fs-extra does

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.

What people build with 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 Idea

Your agent writes many generated files into new nested folders; one call per file creates the folders and saves the text.

fs-extra popularity

72 / 100
Gid Score, #298 overall
314M
downloads a week, npm
9,594
GitHub stars
64
agent projects use it
fs-extra: downloads per weeknpm, fs-extra 313,721,074
fs-extra: GitHub starsjprichardson/node-fs-extra 9,594

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How fs-extra is used

  • fs-extra is a dependency in 64 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.3% of the 4,867 JavaScript/TypeScript ones), #22 of 408 in utilities.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 169; those are left out of every share on this page.
  • Projects that use it most often also use chalk (39.1%), Vitest (53.1%), tsx (42.2%).

By coding agent

40 projects, 1.2%
33 projects, 1.1%
26 projects, 1.1%
16 projects, 3.4%
6 projects, 2.2%
5 projects, 1.5%

Often used with

In 39.1% of its projects
In 53.1% of its projects
In 42.2% of its projects
In 28.1% of its projects
In 28.1% of its projects
In 79.7% of its projects
In 28.1% of its projects
In 25.0% of its projects

More about fs-extra

More in Utilities

Alternatives

fs-extra This page

MITGid 72314M/wk

rimraf

Pick rimraf when all you need is to delete folders, also from an npm script on any system.

ShellJS

Pick ShellJS when you want Unix-style commands like cp -r, rm -rf, sed and grep inside a Node.js script.

write-file-atomic

Pick write-file-atomic when a half-written file after a crash would hurt, for example a settings file.

Compare fs-extra with another tool

Get started

Tell your AI assistant

“Use the npm package fs-extra (pin fs-extra@11.4.1, Node.js 14.14+) for file work in this Node.js script: emptyDir the dist folder, copy the template folder into it, then outputJson the build info; use await and catch errors.”

  1. Add fs-extra to your Node.js project.

    npm install fs-extra

    From github.com/jprichardson/node-fs-extra/blob/master/README.md

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

    const fs = require('fs-extra')

    From github.com/jprichardson/node-fs-extra/blob/master/README.md

  3. 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'
    

    From github.com/jprichardson/node-fs-extra/blob/master/README.md

Mistakes to avoid

import { readFileSync, copy } from 'fs-extra/esm'
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.

require('fs-extra/lib/copy')
require('fs-extra') and call fs.copy(...)

Since version 11 the package only exposes its main entry and fs-extra/esm; deep paths throw.

fs.copy(src, dest, { overwrite: false }) and assuming an existing file means an error
{ 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.

fs.copy('photos', 'backup') expecting backup/photos
fs.copy('photos', 'backup/photos')

Copying a folder copies its contents into the destination, not the folder itself.

fs.access(file, fs.F_OK) on Node.js 24
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).