Filesystem
fs/promises.realpath()
Resolves symbolic links to a canonical existing path. This observation is not a permanent authorization guarantee. Tested on Node.js 22.16.0. Example output (one line per entry): ["true"].
Formal Syntax & Structure
nodejs syntaxnodejs
realpath(path[, options])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| path | string | URL | Existing path. |
| options | object | string | Encoding options. |
Return Value
Promise<string | Buffer>
Resolved path.
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.realpath(q) === await fs.realpath(p));}finally { await fs.rm(dir, { recursive: true, force: true });}