Path

path.resolve()

Builds an absolute path, evaluating segments from the right until an absolute base is available. Tested on Node.js 22.16.0. An absolute later segment can replace an earlier base. Never accept arbitrary segments as authorized filenames.

Formal Syntax & Structure

nodejs syntaxnodejs
path.resolve([...paths])

Parameters & Attributes

NameTypeDescription
paths...stringPath segments; cwd supplies a base if needed.

Return Value

string

Absolute normalized path.

Working Example

Example Snippetnodejs
import path from 'node:path';console.log(path.posix.resolve('/catalog','/public','book.json'));
Node.js Reference