Node.js path.toNamespacedPath() Method Last Updated : 08 Oct, 2021 Comments Improve Suggest changes Like Article Like Report The path.toNamespacedPath() method is used to find the equivalent namespace-prefixed path from the given path. This method is meaningful only on Windows Systems. It would return the same path without modification on POSIX systems. If the path is not a string, it would be returned without modification. Syntax: path.toNamespacedPath( path ) Parameters: This function accepts single parameter as mentioned above and described below: path: It is an string which contains the path that has to be converted. Return Value: It returns a string with an equivalent namespace-prefixed path. Below programs illustrate the path.toNamespacedPath() method: Example 1: javascript // Import the path module const path = require('path'); let originalPath = "C:\\Windows\\users"; console.log("Original Path:", originalPath); let nameSpacedPath = path.toNamespacedPath(originalPath); console.log("Namespaced Path:", nameSpacedPath); Output: Original Path: C:\Windows\users Namespaced Path: \\?\C:\Windows\users Example 2: javascript // Import the path module const path = require('path'); let originalPath = "C:\\Windows\\users\\..\\admin"; console.log("Original Path:", originalPath); let nameSpacedPath = path.toNamespacedPath(originalPath); console.log("Namespaced Path:", nameSpacedPath); Output: Original Path: C:\Windows\users\..\admin Namespaced Path: \\?\C:\Windows\admin Reference: https://nodejs.org/api/path.html#path_path_tonamespacedpath_path Comment More infoAdvertise with us Next Article Node.js path.toNamespacedPath() Method sayantanm19 Follow Improve Article Tags : Web Technologies Node.js Node.js-path-module Similar Reads Node.js path.basename() Method The path.basename() method is used to get the filename portion of a path to the file. The trailing directory separators are ignored when using this method. Syntax: path.basename( path, extension ) Parameters: This method accepts two parameters as mentioned above and described below: path: It is the 1 min read Node.js path.dirname() Method The path.dirname() method is used to get the directory name of the given path. It ignores the respective platform's trailing directory separators. Syntax: path.dirname( path ) Parameters: This function accepts one parameter as mentioned above and described below: path: It is the file path that would 1 min read Node.js path.extname() Method The path.extname() method is used to get the extension portion of a file path. The extension string returned from the last occurrence of a period (.) in the path to the end of the path string. If there are no periods in the file path, then an empty string is returned. Syntax: path.extname( path ) Pa 2 min read Node.js path.format() Method The path.format() method is used to return a path string from the given path object. The method has some rules where one path property gets more priority over another: The "root" parameter of the path object is ignored if the "dir" parameter is provided. The "ext" and "name" parameter of the path ob 3 min read Node.js path.isAbsolute() Method The path.isAbsolute() method is used to check whether the given path is an absolute path or not. An absolute path is defined as a path that contains the complete details needed to locate a file. Syntax: path.isAbsolute( path ) Parameters: This method accepts single parameter path which holds the fil 1 min read Node.js path.join() Method The path.join() method in Node.js is part of the Path module, which is used for handling and transforming file paths. The method is used to join multiple path segments together into one complete path, ensuring that the resulting path is formatted correctly for the current operating system. In this a 2 min read Node.js path.normalize() Method The path.normalize() method is used to normalize the given path. Normalization resolves the (.) and (..) segments of the path to their correct form. If the method encounters multiple path separators, it replaces all of them by a single platform-specific path separator. This method preserves all trai 1 min read Node.js path.parse() Method The path.parse() method is used to return an object whose properties represent the given path. This method returns the following properties: root (root name) dir (directory name) base (filename with extension) ext (only extension) name (only filename) The values of these properties may be different 2 min read Node.js path.relative() Method The path.relative() method is used to find the relative path from a given path to another path based on the current working directory. If both the given paths are the same, it would resolve to a zero-length string. Syntax: path.relative( from, to ) Parameters: This method accept two parameters as me 1 min read Node path.resolve() Method The path.resolve() method takes a sequence of paths or path segments and resolves them into an absolute path. It processes the paths from right to left and appends each path until an absolute path is constructed.Node path.resolve method The path.resolve() method in Node.js helps create a full, absol 3 min read Like