Node.js path.join() Method

❮ Path Module


Example

Join several segments into one path:

var path = require('path');

var x = path.join('Users', 'Refsnes', 'demo_path.js');

console.log(x);
Run example »

Definition and Usage

The path.join() method joins the specified path segments into one path.

You can specify as many path segments as you like.

The specified path segments must be strings, separated by comma.


Syntax

path.join(paths);

Parameter Values

Parameter Description
paths Required. Series of path segments to join into one path

Technical Details

Return Value: A String, representing the joined path
Node.js Version: 0.1.16

More Examples

Example

Add a '..' as one of the segments, and the join method will resolve it:

var path = require('path');

var x = path.join('Users', 'Refsnes', '..', 'demo_path.js');

console.log(x);
Run example »

❮ Path Module

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.