fs-extra is a Node.js module that extends the native fs object with additional file system methods and promise support.
The native fs module requires developers to install separate packages like mkdirp, rimraf, and ncp to handle common tasks such as creating nested directories, removing directory trees, and copying files. fs-extra consolidates these capabilities into a single module by adding methods like copy, remove, mkdirs, move, ensureDir, ensureFile, outputFile, readJson, and writeJson. It wraps all async methods to return promises when no callback is provided, enabling both callback-based and promise-based workflows. The module also integrates graceful-fs to prevent EMFILE errors that can occur when too many file handles are open simultaneously.
fs-extra is designed as a drop-in replacement for the native fs module, meaning you can substitute it directly without changing your existing code. It suits any Node.js project that performs file system operations beyond what the standard library provides. The module supports both CommonJS and ESM imports, though ESM users must still import fs or fs/promises separately. Both synchronous and asynchronous versions of each method are available, with async methods supporting callbacks, promises, and async/await patterns.
The project maintains a clear separation between core functionality and specialized concerns. Walk functionality was removed in version 2.0.0 and is now available through separate packages, keeping the module focused. A CLI wrapper is available as a third-party tool for running fs-extra operations from the command line or npm scripts. TypeScript support is documented for users working in typed environments.