Node.js
fs API Reference
Node.js fs module for filesystem access including reading, writing, listing and inspecting paths.
By EZ4Code Team
fs
Promise-based and synchronous filesystem operations.
fs.readFile(path, options?) -> Promise<Buffer | string>Asynchronously reads the entire contents of a file. Set encoding to receive a string.
Returns: Promise<Buffer | string>
fs.writeFile(path, data, options?) -> Promise<void>Asynchronously writes data to a file, replacing the file if it already exists.
Returns: Promise<void>
fs.readdir(path, options?) -> Promise<string[] | Dirent[]>Asynchronously reads the contents of a directory, returning names or Dirent objects with withFileTypes.
Returns: Promise<string[] | Dirent[]>
fs.stat(path, options?) -> Promise<Stats>Asynchronously resolves file metadata such as size, mtime and type.
Returns: Promise<Stats>
fs.mkdir(path, options?) -> Promise<string | undefined>Asynchronously creates a directory; recursive: true creates parent directories as needed.
Returns: Promise<string | undefined>