path.join()

Joins path segments using the platform separator and normalizes the result.

Since Node 0.x Spec ↗

Syntax

path.join(...paths)

Parameters

NameTypeRequiredDescription
paths ...string Yes A sequence of path segments to join.

Returns

string — The normalized joined path.

Examples

import { join } from 'node:path';

console.log(join('src', 'lib', 'index.js'));
Output
src/lib/index.js
import { join } from 'node:path';

console.log(join('/app', 'data', '..', 'logs'));
Output
/app/logs

Notes

Normalizes `.` and `..` and collapses redundant separators. Unlike `resolve` it does not anchor to an absolute path. Use the platform separator automatically (backslash on Windows).

See also