Filesystem

fs/promises.lstat()

Inspects the directory entry itself, unlike stat which follows a symbolic link. Link handling alone does not eliminate path races. Tested on Node.js 22.16.0. Example output (one line per entry): ["true true"].

Formal Syntax & Structure

nodejs syntaxnodejs
lstat(path[, options])

Parameters & Attributes

NameTypeDescription
pathstring | URLEntry path.
optionsobjectStat options.

Return Value

Promise<Stats>

Entry metadata.

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 q = join(dir, 'alias');    await fs.symlink(p, q);    console.log((await fs.lstat(q)).isSymbolicLink(), (await fs.stat(q)).isFile());}finally {    await fs.rm(dir, { recursive: true, force: true });}
Node.js Reference