{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.0.json","id":"path","path":"/path","type":"module","module":"path","title":"Path","introducedIn":"v0.10.0","sourceLink":{"path":"lib/path.js","url":"https://github.com/nodejs/node/blob/HEAD/lib/path.js"},"stability":{"index":"2","description":"Stable"},"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `node:path` module provides utilities for working with file and directory\npaths. It can be accessed using:\n\n```cjs\nconst path = require('node:path');\n```\n\n```mjs\nimport path from 'node:path';\n```","summary":"The `node:path` module provides utilities for working with file and directory paths. It can be accessed using:","examples":[{"language":"cjs","displayName":null,"code":"const path = require('node:path');"},{"language":"mjs","displayName":null,"code":"import path from 'node:path';"}],"children":[{"kind":"section","id":"windows-vs-posix","name":"Windows vs. POSIX","title":"Windows vs. POSIX","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The default operation of the `node:path` module varies based on the operating\nsystem on which a Node.js application is running. Specifically, when running on\na Windows operating system, the `node:path` module will assume that\nWindows-style paths are being used.\n\nSo using `path.basename()` might yield different results on POSIX and Windows:\n\nOn POSIX:\n\n```js\npath.basename('C:\\\\temp\\\\myfile.html');\n// Returns: 'C:\\\\temp\\\\myfile.html'\n```\n\nOn Windows:\n\n```js\npath.basename('C:\\\\temp\\\\myfile.html');\n// Returns: 'myfile.html'\n```\n\nTo achieve consistent results when working with Windows file paths on any\noperating system, use [`path.win32`](#pathwin32):\n\nOn POSIX and Windows:\n\n```js\npath.win32.basename('C:\\\\temp\\\\myfile.html');\n// Returns: 'myfile.html'\n```\n\nTo achieve consistent results when working with POSIX file paths on any\noperating system, use [`path.posix`](#pathposix):\n\nOn POSIX and Windows:\n\n```js\npath.posix.basename('/tmp/myfile.html');\n// Returns: 'myfile.html'\n```\n\nOn Windows Node.js follows the concept of per-drive working directory.\nThis behavior can be observed when using a drive path without a backslash. For\nexample, `path.resolve('C:\\\\')` can potentially return a different result than\n`path.resolve('C:')`. For more information, see\n[this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths).","summary":"The default operation of the `node:path` module varies based on the operating system on which a Node.js application is running. Specifically, when running on a Windows operating system, the `node:path` module will assume that Windows-style paths are being used.","examples":[{"language":"js","displayName":null,"code":"path.basename('C:\\\\temp\\\\myfile.html');\n// Returns: 'C:\\\\temp\\\\myfile.html'"},{"language":"js","displayName":null,"code":"path.basename('C:\\\\temp\\\\myfile.html');\n// Returns: 'myfile.html'"},{"language":"js","displayName":null,"code":"path.win32.basename('C:\\\\temp\\\\myfile.html');\n// Returns: 'myfile.html'"},{"language":"js","displayName":null,"code":"path.posix.basename('/tmp/myfile.html');\n// Returns: 'myfile.html'"}],"children":[]},{"kind":"method","id":"pathbasenamepath-suffix","name":"basename","title":"`path.basename(path[, suffix])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.25"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5348","commit":null,"description":"Passing a non-string as the `path` argument will throw now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"suffix","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"An optional suffix to remove","default":null,"optional":true,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.basename()` method returns the last portion of a `path`, similar to\nthe Unix `basename` command. Trailing [directory separators](#pathsep) are\nignored.\n\n```js\npath.basename('/foo/bar/baz/asdf/quux.html');\n// Returns: 'quux.html'\n\npath.basename('/foo/bar/baz/asdf/quux.html', '.html');\n// Returns: 'quux'\n```\n\nAlthough Windows usually treats file names, including file extensions, in a\ncase-insensitive manner, this function does not. For example, `C:\\\\foo.html` and\n`C:\\\\foo.HTML` refer to the same file, but `basename` treats the extension as a\ncase-sensitive string:\n\n```js\npath.win32.basename('C:\\\\foo.html', '.html');\n// Returns: 'foo'\n\npath.win32.basename('C:\\\\foo.HTML', '.html');\n// Returns: 'foo.HTML'\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if `path` is not a string or if `suffix` is given\nand is not a string.","summary":"The `path.basename()` method returns the last portion of a `path`, similar to the Unix `basename` command. Trailing directory separators are ignored.","examples":[{"language":"js","displayName":null,"code":"path.basename('/foo/bar/baz/asdf/quux.html');\n// Returns: 'quux.html'\n\npath.basename('/foo/bar/baz/asdf/quux.html', '.html');\n// Returns: 'quux'"},{"language":"js","displayName":null,"code":"path.win32.basename('C:\\\\foo.html', '.html');\n// Returns: 'foo'\n\npath.win32.basename('C:\\\\foo.HTML', '.html');\n// Returns: 'foo.HTML'"}],"children":[]},{"kind":"property","id":"pathdelimiter","name":"delimiter","title":"`path.delimiter`","scope":"module","overloadOf":null,"stability":null,"added":["v0.9.3"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"Provides the platform-specific path delimiter:\n\n* `;` for Windows\n* `:` for POSIX\n\nFor example, on POSIX:\n\n```js\nconsole.log(process.env.PATH);\n// Prints: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'\n\nprocess.env.PATH.split(path.delimiter);\n// Returns: ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']\n```\n\nOn Windows:\n\n```js\nconsole.log(process.env.PATH);\n// Prints: 'C:\\Windows\\system32;C:\\Windows;C:\\Program Files\\node\\'\n\nprocess.env.PATH.split(path.delimiter);\n// Returns ['C:\\\\Windows\\\\system32', 'C:\\\\Windows', 'C:\\\\Program Files\\\\node\\\\']\n```","summary":"Provides the platform-specific path delimiter:","examples":[{"language":"js","displayName":null,"code":"console.log(process.env.PATH);\n// Prints: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin'\n\nprocess.env.PATH.split(path.delimiter);\n// Returns: ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin']"},{"language":"js","displayName":null,"code":"console.log(process.env.PATH);\n// Prints: 'C:\\Windows\\system32;C:\\Windows;C:\\Program Files\\node\\'\n\nprocess.env.PATH.split(path.delimiter);\n// Returns ['C:\\\\Windows\\\\system32', 'C:\\\\Windows', 'C:\\\\Program Files\\\\node\\\\']"}],"children":[]},{"kind":"method","id":"pathdirnamepath","name":"dirname","title":"`path.dirname(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5348","commit":null,"description":"Passing a non-string as the `path` argument will throw now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.dirname()` method returns the directory name of a `path`, similar to\nthe Unix `dirname` command. Trailing directory separators are ignored, see\n[`path.sep`](#pathsep).\n\n```js\npath.dirname('/foo/bar/baz/asdf/quux');\n// Returns: '/foo/bar/baz/asdf'\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if `path` is not a string.","summary":"The `path.dirname()` method returns the directory name of a `path`, similar to the Unix `dirname` command. Trailing directory separators are ignored, see `path.sep`.","examples":[{"language":"js","displayName":null,"code":"path.dirname('/foo/bar/baz/asdf/quux');\n// Returns: '/foo/bar/baz/asdf'"}],"children":[]},{"kind":"method","id":"pathextnamepath","name":"extname","title":"`path.extname(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.25"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.0.0"],"prUrl":"https://github.com/nodejs/node/pull/5348","commit":null,"description":"Passing a non-string as the `path` argument will throw now."}],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.extname()` method returns the extension of the `path`, from the last\noccurrence of the `.` (period) character to end of string in the last portion of\nthe `path`. If there is no `.` in the last portion of the `path`, or if\nthere are no `.` characters other than the first character of\nthe basename of `path` (see `path.basename()`) , an empty string is returned.\n\n```js\npath.extname('index.html');\n// Returns: '.html'\n\npath.extname('index.coffee.md');\n// Returns: '.md'\n\npath.extname('index.');\n// Returns: '.'\n\npath.extname('index');\n// Returns: ''\n\npath.extname('.index');\n// Returns: ''\n\npath.extname('.index.md');\n// Returns: '.md'\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if `path` is not a string.","summary":"The `path.extname()` method returns the extension of the `path`, from the last occurrence of the `.` (period) character to end of string in the last portion of the `path`. If there is no `.` in the last portion of the `path`, or if there are no `.` characters other than the first character of the basename of `path` (see `path.basename()`) , an empty string is returned.","examples":[{"language":"js","displayName":null,"code":"path.extname('index.html');\n// Returns: '.html'\n\npath.extname('index.coffee.md');\n// Returns: '.md'\n\npath.extname('index.');\n// Returns: '.'\n\npath.extname('index');\n// Returns: ''\n\npath.extname('.index');\n// Returns: ''\n\npath.extname('.index.md');\n// Returns: '.md'"}],"children":[]},{"kind":"method","id":"pathformatpathobject","name":"format","title":"`path.format(pathObject)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v19.0.0"],"prUrl":"https://github.com/nodejs/node/pull/44349","commit":null,"description":"The dot will be added if it is not specified in `ext`."}],"signature":{"parameters":[{"name":"pathObject","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"Any JavaScript object having the following properties:","default":null,"optional":false,"rest":false,"properties":[{"name":"dir","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"root","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"base","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"name","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"ext","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.format()` method returns a path string from an object. This is the\nopposite of [`path.parse()`](#pathparsepath).\n\nWhen providing properties to the `pathObject` remember that there are\ncombinations where one property has priority over another:\n\n* `pathObject.root` is ignored if `pathObject.dir` is provided\n* `pathObject.ext` and `pathObject.name` are ignored if `pathObject.base` exists\n\nFor example, on POSIX:\n\n```js\n// If `dir`, `root` and `base` are provided,\n// `${dir}${path.sep}${base}`\n// will be returned. `root` is ignored.\npath.format({\n  root: '/ignored',\n  dir: '/home/user/dir',\n  base: 'file.txt',\n});\n// Returns: '/home/user/dir/file.txt'\n\n// `root` will be used if `dir` is not specified.\n// If only `root` is provided or `dir` is equal to `root` then the\n// platform separator will not be included. `ext` will be ignored.\npath.format({\n  root: '/',\n  base: 'file.txt',\n  ext: 'ignored',\n});\n// Returns: '/file.txt'\n\n// `name` + `ext` will be used if `base` is not specified.\npath.format({\n  root: '/',\n  name: 'file',\n  ext: '.txt',\n});\n// Returns: '/file.txt'\n\n// The dot will be added if it is not specified in `ext`.\npath.format({\n  root: '/',\n  name: 'file',\n  ext: 'txt',\n});\n// Returns: '/file.txt'\n```\n\nOn Windows:\n\n```js\npath.format({\n  dir: 'C:\\\\path\\\\dir',\n  base: 'file.txt',\n});\n// Returns: 'C:\\\\path\\\\dir\\\\file.txt'\n```","summary":"The `path.format()` method returns a path string from an object. This is the opposite of `path.parse()`.","examples":[{"language":"js","displayName":null,"code":"// If `dir`, `root` and `base` are provided,\n// `${dir}${path.sep}${base}`\n// will be returned. `root` is ignored.\npath.format({\n  root: '/ignored',\n  dir: '/home/user/dir',\n  base: 'file.txt',\n});\n// Returns: '/home/user/dir/file.txt'\n\n// `root` will be used if `dir` is not specified.\n// If only `root` is provided or `dir` is equal to `root` then the\n// platform separator will not be included. `ext` will be ignored.\npath.format({\n  root: '/',\n  base: 'file.txt',\n  ext: 'ignored',\n});\n// Returns: '/file.txt'\n\n// `name` + `ext` will be used if `base` is not specified.\npath.format({\n  root: '/',\n  name: 'file',\n  ext: '.txt',\n});\n// Returns: '/file.txt'\n\n// The dot will be added if it is not specified in `ext`.\npath.format({\n  root: '/',\n  name: 'file',\n  ext: 'txt',\n});\n// Returns: '/file.txt'"},{"language":"js","displayName":null,"code":"path.format({\n  dir: 'C:\\\\path\\\\dir',\n  base: 'file.txt',\n});\n// Returns: 'C:\\\\path\\\\dir\\\\file.txt'"}],"children":[]},{"kind":"method","id":"pathmatchesglobpath-pattern","name":"matchesGlob","title":"`path.matchesGlob(path, pattern)`","scope":"module","overloadOf":null,"stability":null,"added":["v22.5.0","v20.17.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v24.8.0","v22.20.0"],"prUrl":"https://github.com/nodejs/node/pull/59572","commit":null,"description":"Marking the API stable."}],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The path to glob-match against.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"pattern","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The glob to check the path against.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Whether or not the `path` matched the `pattern`."}},"description":"The `path.matchesGlob()` method determines if `path` matches the `pattern`.\n\nFor example:\n\n```js\npath.matchesGlob('/foo/bar', '/foo/*'); // true\npath.matchesGlob('/foo/bar*', 'foo/bird'); // false\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if `path` or `pattern` are not strings.","summary":"The `path.matchesGlob()` method determines if `path` matches the `pattern`.","examples":[{"language":"js","displayName":null,"code":"path.matchesGlob('/foo/bar', '/foo/*'); // true\npath.matchesGlob('/foo/bar*', 'foo/bird'); // false"}],"children":[]},{"kind":"method","id":"pathisabsolutepath","name":"isAbsolute","title":"`path.isAbsolute(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.2"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":""}},"description":"The `path.isAbsolute()` method determines if the literal `path` is absolute.\nTherefore, it’s not safe for mitigating path traversals.\n\nIf the given `path` is a zero-length string, `false` will be returned.\n\nFor example, on POSIX:\n\n```js\npath.isAbsolute('/foo/bar');   // true\npath.isAbsolute('/baz/..');    // true\npath.isAbsolute('/baz/../..'); // true\npath.isAbsolute('qux/');       // false\npath.isAbsolute('.');          // false\n```\n\nOn Windows:\n\n```js\npath.isAbsolute('//server');    // true\npath.isAbsolute('\\\\\\\\server');  // true\npath.isAbsolute('C:/foo/..');   // true\npath.isAbsolute('C:\\\\foo\\\\..'); // true\npath.isAbsolute('bar\\\\baz');    // false\npath.isAbsolute('bar/baz');     // false\npath.isAbsolute('.');           // false\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if `path` is not a string.","summary":"The `path.isAbsolute()` method determines if the literal `path` is absolute. Therefore, it’s not safe for mitigating path traversals.","examples":[{"language":"js","displayName":null,"code":"path.isAbsolute('/foo/bar');   // true\npath.isAbsolute('/baz/..');    // true\npath.isAbsolute('/baz/../..'); // true\npath.isAbsolute('qux/');       // false\npath.isAbsolute('.');          // false"},{"language":"js","displayName":null,"code":"path.isAbsolute('//server');    // true\npath.isAbsolute('\\\\\\\\server');  // true\npath.isAbsolute('C:/foo/..');   // true\npath.isAbsolute('C:\\\\foo\\\\..'); // true\npath.isAbsolute('bar\\\\baz');    // false\npath.isAbsolute('bar/baz');     // false\npath.isAbsolute('.');           // false"}],"children":[]},{"kind":"method","id":"pathjoinpaths","name":"join","title":"`path.join([...paths])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.16"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"paths","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"A sequence of path segments","default":null,"optional":true,"rest":true,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.join()` method joins all given `path` segments together using the\nplatform-specific separator as a delimiter, then normalizes the resulting path.\n\nZero-length `path` segments are ignored. If the joined path string is a\nzero-length string then `'.'` will be returned, representing the current\nworking directory.\n\n```js\npath.join('/foo', 'bar', 'baz/asdf', 'quux', '..');\n// Returns: '/foo/bar/baz/asdf'\n\npath.join('foo', {}, 'bar');\n// Throws 'TypeError: Path must be a string. Received {}'\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if any of the path segments is not a string.","summary":"The `path.join()` method joins all given `path` segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.","examples":[{"language":"js","displayName":null,"code":"path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');\n// Returns: '/foo/bar/baz/asdf'\n\npath.join('foo', {}, 'bar');\n// Throws 'TypeError: Path must be a string. Received {}'"}],"children":[]},{"kind":"method","id":"pathnormalizepath","name":"normalize","title":"`path.normalize(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.1.23"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.normalize()` method normalizes the given `path`, resolving `'..'` and\n`'.'` segments.\n\nWhen multiple, sequential path segment separation characters are found (e.g.\n`/` on POSIX and either `\\` or `/` on Windows), they are replaced by a single\ninstance of the platform-specific path segment separator (`/` on POSIX and\n`\\` on Windows). Trailing separators are preserved.\n\nIf the `path` is a zero-length string, `'.'` is returned, representing the\ncurrent working directory.\n\nOn POSIX, the types of normalization applied by this function do not strictly\nadhere to the POSIX specification. For example, this function will replace two\nleading forward slashes with a single slash as if it was a regular absolute\npath, whereas a few POSIX systems assign special meaning to paths beginning with\nexactly two forward slashes. Similarly, other substitutions performed by this\nfunction, such as removing `..` segments, may change how the underlying system\nresolves the path.\n\nFor example, on POSIX:\n\n```js\npath.normalize('/foo/bar//baz/asdf/quux/..');\n// Returns: '/foo/bar/baz/asdf'\n```\n\nOn Windows:\n\n```js\npath.normalize('C:\\\\temp\\\\\\\\foo\\\\bar\\\\..\\\\');\n// Returns: 'C:\\\\temp\\\\foo\\\\'\n```\n\nSince Windows recognizes multiple path separators, both separators will be\nreplaced by instances of the Windows preferred separator (`\\`):\n\n```js\npath.win32.normalize('C:////temp\\\\\\\\/\\\\/\\\\/foo/bar');\n// Returns: 'C:\\\\temp\\\\foo\\\\bar'\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if `path` is not a string.","summary":"The `path.normalize()` method normalizes the given `path`, resolving `'..'` and `'.'` segments.","examples":[{"language":"js","displayName":null,"code":"path.normalize('/foo/bar//baz/asdf/quux/..');\n// Returns: '/foo/bar/baz/asdf'"},{"language":"js","displayName":null,"code":"path.normalize('C:\\\\temp\\\\\\\\foo\\\\bar\\\\..\\\\');\n// Returns: 'C:\\\\temp\\\\foo\\\\'"},{"language":"js","displayName":null,"code":"path.win32.normalize('C:////temp\\\\\\\\/\\\\/\\\\/foo/bar');\n// Returns: 'C:\\\\temp\\\\foo\\\\bar'"}],"children":[]},{"kind":"method","id":"pathparsepath","name":"parse","title":"`path.parse(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":""}},"description":"The `path.parse()` method returns an object whose properties represent\nsignificant elements of the `path`. Trailing directory separators are ignored,\nsee [`path.sep`](#pathsep).\n\nThe returned object will have the following properties:\n\n* `dir` {string}\n* `root` {string}\n* `base` {string}\n* `name` {string}\n* `ext` {string}\n\nFor example, on POSIX:\n\n```js\npath.parse('/home/user/dir/file.txt');\n// Returns:\n// { root: '/',\n//   dir: '/home/user/dir',\n//   base: 'file.txt',\n//   ext: '.txt',\n//   name: 'file' }\n```\n\n```text\n┌─────────────────────┬────────────┐\n│          dir        │    base    │\n├──────┬              ├──────┬─────┤\n│ root │              │ name │ ext │\n\"  /    home/user/dir / file  .txt \"\n└──────┴──────────────┴──────┴─────┘\n(All spaces in the \"\" line should be ignored. They are purely for formatting.)\n```\n\nOn Windows:\n\n```js\npath.parse('C:\\\\path\\\\dir\\\\file.txt');\n// Returns:\n// { root: 'C:\\\\',\n//   dir: 'C:\\\\path\\\\dir',\n//   base: 'file.txt',\n//   ext: '.txt',\n//   name: 'file' }\n```\n\n```text\n┌─────────────────────┬────────────┐\n│          dir        │    base    │\n├──────┬              ├──────┬─────┤\n│ root │              │ name │ ext │\n\" C:\\      path\\dir   \\ file  .txt \"\n└──────┴──────────────┴──────┴─────┘\n(All spaces in the \"\" line should be ignored. They are purely for formatting.)\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if `path` is not a string.","summary":"The `path.parse()` method returns an object whose properties represent significant elements of the `path`. Trailing directory separators are ignored, see `path.sep`.","examples":[{"language":"js","displayName":null,"code":"path.parse('/home/user/dir/file.txt');\n// Returns:\n// { root: '/',\n//   dir: '/home/user/dir',\n//   base: 'file.txt',\n//   ext: '.txt',\n//   name: 'file' }"},{"language":"text","displayName":null,"code":"┌─────────────────────┬────────────┐\n│          dir        │    base    │\n├──────┬              ├──────┬─────┤\n│ root │              │ name │ ext │\n\"  /    home/user/dir / file  .txt \"\n└──────┴──────────────┴──────┴─────┘\n(All spaces in the \"\" line should be ignored. They are purely for formatting.)"},{"language":"js","displayName":null,"code":"path.parse('C:\\\\path\\\\dir\\\\file.txt');\n// Returns:\n// { root: 'C:\\\\',\n//   dir: 'C:\\\\path\\\\dir',\n//   base: 'file.txt',\n//   ext: '.txt',\n//   name: 'file' }"},{"language":"text","displayName":null,"code":"┌─────────────────────┬────────────┐\n│          dir        │    base    │\n├──────┬              ├──────┬─────┤\n│ root │              │ name │ ext │\n\" C:\\      path\\dir   \\ file  .txt \"\n└──────┴──────────────┴──────┴─────┘\n(All spaces in the \"\" line should be ignored. They are purely for formatting.)"}],"children":[]},{"kind":"property","id":"pathposix","name":"posix","title":"`path.posix`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.3.0"],"prUrl":"https://github.com/nodejs/node/pull/34962","commit":null,"description":"Exposed as `require('path/posix')`."}],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"The `path.posix` property provides access to POSIX specific implementations\nof the `path` methods.\n\nThe API is accessible via `require('node:path').posix` or `require('node:path/posix')`.","summary":"The `path.posix` property provides access to POSIX specific implementations of the `path` methods.","examples":[],"children":[]},{"kind":"method","id":"pathrelativefrom-to","name":"relative","title":"`path.relative(from, to)`","scope":"module","overloadOf":null,"stability":null,"added":["v0.5.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v6.8.0"],"prUrl":"https://github.com/nodejs/node/pull/8523","commit":null,"description":"On Windows, the leading slashes for UNC paths are now included in the return value."}],"signature":{"parameters":[{"name":"from","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]},{"name":"to","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.relative()` method returns the relative path from `from` to `to` based\non the current working directory. If `from` and `to` each resolve to the same\npath (after calling `path.resolve()` on each), a zero-length string is returned.\n\nIf a zero-length string is passed as `from` or `to`, the current working\ndirectory will be used instead of the zero-length strings.\n\nFor example, on POSIX:\n\n```js\npath.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb');\n// Returns: '../../impl/bbb'\n```\n\nOn Windows:\n\n```js\npath.relative('C:\\\\orandea\\\\test\\\\aaa', 'C:\\\\orandea\\\\impl\\\\bbb');\n// Returns: '..\\\\..\\\\impl\\\\bbb'\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if either `from` or `to` is not a string.","summary":"The `path.relative()` method returns the relative path from `from` to `to` based on the current working directory. If `from` and `to` each resolve to the same path (after calling `path.resolve()` on each), a zero-length string is returned.","examples":[{"language":"js","displayName":null,"code":"path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb');\n// Returns: '../../impl/bbb'"},{"language":"js","displayName":null,"code":"path.relative('C:\\\\orandea\\\\test\\\\aaa', 'C:\\\\orandea\\\\impl\\\\bbb');\n// Returns: '..\\\\..\\\\impl\\\\bbb'"}],"children":[]},{"kind":"method","id":"pathresolvepaths","name":"resolve","title":"`path.resolve([...paths])`","scope":"module","overloadOf":null,"stability":null,"added":["v0.3.4"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"paths","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"A sequence of paths or path segments","default":null,"optional":true,"rest":true,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"The `path.resolve()` method resolves a sequence of paths or path segments into\nan absolute path.\n\nThe given sequence of paths is processed from right to left, with each\nsubsequent `path` prepended until an absolute path is constructed.\nFor instance, given the sequence of path segments: `/foo`, `/bar`, `baz`,\ncalling `path.resolve('/foo', '/bar', 'baz')` would return `/bar/baz`\nbecause `'baz'` is not an absolute path but `'/bar' + '/' + 'baz'` is.\n\nIf, after processing all given `path` segments, an absolute path has not yet\nbeen generated, the current working directory is used.\n\nThe resulting path is normalized and trailing slashes are removed unless the\npath is resolved to the root directory.\n\nZero-length `path` segments are ignored.\n\nIf no `path` segments are passed, `path.resolve()` will return the absolute path\nof the current working directory.\n\n```js\npath.resolve('/foo/bar', './baz');\n// Returns: '/foo/bar/baz'\n\npath.resolve('/foo/bar', '/tmp/file/');\n// Returns: '/tmp/file'\n\npath.resolve('wwwroot', 'static_files/png/', '../gif/image.gif');\n// If the current working directory is /home/myself/node,\n// this returns '/home/myself/node/wwwroot/static_files/gif/image.gif'\n```\n\nA [`TypeError`](errors.html#class-typeerror) is thrown if any of the arguments is not a string.","summary":"The `path.resolve()` method resolves a sequence of paths or path segments into an absolute path.","examples":[{"language":"js","displayName":null,"code":"path.resolve('/foo/bar', './baz');\n// Returns: '/foo/bar/baz'\n\npath.resolve('/foo/bar', '/tmp/file/');\n// Returns: '/tmp/file'\n\npath.resolve('wwwroot', 'static_files/png/', '../gif/image.gif');\n// If the current working directory is /home/myself/node,\n// this returns '/home/myself/node/wwwroot/static_files/gif/image.gif'"}],"children":[]},{"kind":"property","id":"pathsep","name":"sep","title":"`path.sep`","scope":"module","overloadOf":null,"stability":null,"added":["v0.7.9"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"Provides the platform-specific path segment separator:\n\n* `\\` on Windows\n* `/` on POSIX\n\nFor example, on POSIX:\n\n```js\n'foo/bar/baz'.split(path.sep);\n// Returns: ['foo', 'bar', 'baz']\n```\n\nOn Windows:\n\n```js\n'foo\\\\bar\\\\baz'.split(path.sep);\n// Returns: ['foo', 'bar', 'baz']\n```\n\nOn Windows, both the forward slash (`/`) and backward slash (`\\`) are accepted\nas path segment separators; however, the `path` methods only add backward\nslashes (`\\`).","summary":"Provides the platform-specific path segment separator:","examples":[{"language":"js","displayName":null,"code":"'foo/bar/baz'.split(path.sep);\n// Returns: ['foo', 'bar', 'baz']"},{"language":"js","displayName":null,"code":"'foo\\\\bar\\\\baz'.split(path.sep);\n// Returns: ['foo', 'bar', 'baz']"}],"children":[]},{"kind":"method","id":"pathtonamespacedpathpath","name":"toNamespacedPath","title":"`path.toNamespacedPath(path)`","scope":"module","overloadOf":null,"stability":null,"added":["v9.0.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":""}},"description":"On Windows systems only, returns an equivalent [namespace-prefixed path](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#namespaces) for\nthe given `path`. If `path` is not a string, `path` will be returned without\nmodifications.\n\nThis method is meaningful only on Windows systems. On POSIX systems, the\nmethod is non-operational and always returns `path` without modifications.","summary":"On Windows systems only, returns an equivalent namespace-prefixed path for the given `path`. If `path` is not a string, `path` will be returned without modifications.","examples":[],"children":[]},{"kind":"property","id":"pathwin32","name":"win32","title":"`path.win32`","scope":"module","overloadOf":null,"stability":null,"added":["v0.11.15"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[{"versions":["v15.3.0"],"prUrl":"https://github.com/nodejs/node/pull/34962","commit":null,"description":"Exposed as `require('path/win32')`."}],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"The `path.win32` property provides access to Windows-specific implementations\nof the `path` methods.\n\nThe API is accessible via `require('node:path').win32` or `require('node:path/win32')`.","summary":"The `path.win32` property provides access to Windows-specific implementations of the `path` methods.","examples":[],"children":[]}]}