Filesystem

fs/promises.statfs()

Reads filesystem capacity information, not per-user quota or a reservation of future free space. Tested on Node.js 22.16.0. Example output (one line per entry): ["bigint true true"].

Formal Syntax & Structure

nodejs syntaxnodejs
statfs(path[, options])

Parameters & Attributes

NameTypeDescription
pathstring | URLPath on filesystem.
optionsobjectBigInt option.

Return Value

Promise<StatFs>

Filesystem statistics.

Working Example

Example Snippetnodejs
import * as fs from 'node:fs/promises';import { constants } from 'node:fs';import { join } from 'node:path';import { tmpdir } from 'node:os';const dir = await fs.mkdtemp(join(tmpdir(), 'bytemind-'));try {    const p = join(dir, 'book.txt');    await fs.writeFile(p, 'catalog');    const s = await fs.statfs(dir, { bigint: true });    console.log(typeof s.bsize, s.bsize > 0n, s.blocks >= s.bfree);}finally {    await fs.rm(dir, { recursive: true, force: true });}
Node.js Reference