File system

The node:fs module gives access to the file system: read, write, append, delete, list. It exists in synchronous, callback, and promise versions (node:fs/promises). On a server, prefer the asynchronous version, because the synchronous one blocks the event loop.

Example

import { readFile, writeFile } from 'node:fs/promises';
const txt = await readFile('notes.txt', 'utf8');

Related concepts

The whole glossary