path.join()

Joins path segments using the OS-specific path separator, normalizing the result.

Syntax

nodejs
path.join(...paths)

Example

nodejs
const path = require("path");

path.join("/users", "alice", "docs");
// "/users/alice/docs" on Unix

path.join(__dirname, "public", "index.html");
// Absolute path to public/index.html from current file