• Node.js Video Tutorials

Node.js - Path module



The Path module of Node.js offers utilities for working with file and directory paths. Depending on the type of operating system − POSIX or WINDOWS, the methods given in the Path module may yield varying results.

List of Methods

Following is a list of methods available in the Path Module −

Sr.No Module & Description
1

basename()

This function allows you to retrieve last portion of a specified path.

2

delimiter

It is a platform-specific property, it represents the delimiter (separator) used to separate the file paths in the environment variable named PATH of the current operating system.

3

dirname()

This method is used to retrieve the parent directory for a specified path.

4

extname()

Used to get the extension of the given file, based on the last occurrence of the (.) period character in the path.

5

format()

This method accepts an object representing a path and returns the given path in the string format.

6

isAbsolute()

It will return a Boolean value, which is used to determine whether the given path is absolute or not.

7

join()

Used to join all the given string path segments together by using the platform separator.

8

normalize()

It is used to normalize the given path.

9

parse()

It returns an object whose properties represent significant elements of a path.

10

relative()

It is used to retrieve a relative path from one path to another path based on current working directory.

11

resolve()

It is used to rectify a series of path segments or paths to an absolute path.

12

toNamespacedPath()

It returns an equivalent namespace-prefixed path for the given path.

Advertisements