LANGUAGE » JAVASCRIPT » NODEJS

File System

Usage

Enable interaction with the file system.

js
const fs = require('node:fs'); // CommonJS
import fs from 'node:fs';      // ES module

Read all contents of a file as string:

js
const contents = fs.readFileSync('path/to/file.txt', 'utf8');