SyntaxStudy
Sign Up

path

property

Provides utilities for working with file and directory paths in a cross-platform way.

Syntax

const path = require('path')

Example

javascript
const path = require('path');

path.join('/home', 'user', 'file.txt');
// '/home/user/file.txt'

path.resolve('src', 'app.js');
// Absolute path from cwd

path.dirname('/home/user/file.txt');  // '/home/user'
path.basename('/home/user/file.txt'); // 'file.txt'
path.extname('image.png');            // '.png'
path.parse('/home/user/file.txt');
// { root:'/', dir:'/home/user', base:'file.txt', ext:'.txt', name:'file' }