Path

Node.js path module -- utilities for working with file and directory paths.

Module: node:path Support: Experimental Since: 1.1.0 Docs: Node.js Docs

Static Methods

🟢 basename(path, suffix)
Return the last portion of a path, optionally removing a suffix.
🟢 dirname(path)
Return the directory name of a path.
🟢 extname(path)
Return the extension of the path, from the last '.' to end of string.
🟢 format(pathObject)
Returns a path string from an object (the opposite of path.parse()).
🟢 isAbsolute(path)
Determines whether path is an absolute path.
🟢 join(paths)
Join all arguments together and normalize the resulting path.
🟢 normalize(path)
Normalize a path, resolving '..' and '.' segments.
🟢 parse(path)
Returns an object whose properties represent significant elements of the path.
🟢 relative(from, to)
Returns the relative path from 'from' to 'to'.
🟢 resolve(paths)
Resolve a sequence of paths into an absolute path.
🟢 toNamespacedPath(path)
Returns an equivalent namespace-prefixed path (Windows only; no-op on POSIX).
🟢 matchesGlob(path, pattern)
Returns true if the path matches the given glob pattern.

Properties

🟢 sep
The platform-specific path segment separator.
🟢 delimiter
The platform-specific path delimiter.
🟢 posix
Provides access to POSIX specific implementations of the path methods.
🟢 win32
Provides access to Windows specific implementations of the path methods.

Dictionary ParsedPath

Represents a parsed path object returned by path.parse() and accepted by path.format().

5 members: 2 supported, 3 undocumented

Properties

🟢 root
Represents a parsed path object returned by path.parse()
🟢 dir
Represents a parsed path object returned by path.parse()
⚪ base
→ UTF8String
⚪ ext
→ UTF8String
⚪ name
→ UTF8String

---

Dictionary FormatInputPathObject

Input object for path.format() - all properties are optional.

5 members: 2 supported, 3 undocumented

Properties

🟢 root
Represents a parsed path object returned by path.parse()
🟢 dir
Represents a parsed path object returned by path.parse()
⚪ base
→ UTF8String
⚪ ext
→ UTF8String
⚪ name
→ UTF8String

---