unjs/pathe

🛣️ Drop-in replacement of the Node.js's path module module that ensures paths are normalized

TypeScript

591

236 commits

updated Oct 6, 2026

See the code

README

🛣️ pathe

Universal filesystem path utils

version downloads size

❓ Why

For historical reasons, windows followed MS-DOS and used backslash for separating paths rather than slash used for macOS, Linux, and other Posix operating systems. Nowadays, Windows supports both Slash and Backslash for paths. Node.js's built-in path module in the default operation of the 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 path module will assume that Windows-style paths are being used. This makes inconsistent code behavior between Windows and POSIX.

Compared to popular upath, pathe provides identical exports of Node.js with normalization on all operations and is written in modern ESM/TypeScript and has no dependency on Node.js!

This package is a drop-in replacement of the Node.js's path module module and ensures paths are normalized with slash / and work in environments including Node.js and browsers.

💿 Usage

Install using npm or yarn:

# npm
npm i pathe

# yarn
yarn add pathe

# pnpm
pnpm i pathe

Import:

// ESM / Typescript
import { resolve, matchesGlob } from "pathe";

// CommonJS
const { resolve, matchesGlob } = require("pathe");

Read more about path utils from Node.js documentation and rest assured behavior is consistently like POSIX regardless of your input paths format and running platform (the only exception is delimiter constant export, it will be set to ; on windows platform).

Extra utilities

Pathe exports some extra utilities that do not exist in standard Node.js path module. In order to use them, you can import from pathe/utils subpath:

import { filename, normalizeAliases, resolveAlias, reverseResolveAlias } from "pathe/utils";

License

Made with 💛 Published under the MIT license.

Some code was used from the Node.js project. Glob supported is powered by zeptomatch.

Significant stargazers

btea

299 followers · starred Jan 2025

Corentin Leruth

115 followers · starred Sep 2024

ZHAO Jin-Xiang

417 followers · starred Dec 2024

Mao Mr

95 followers · starred Jun 2023

unjs/pathe

🛣️ Drop-in replacement of the Node.js's path module module that ensures paths are normalized

TypeScript

591

236 commits

updated Oct 6, 2026

See the code

README

🛣️ pathe

Universal filesystem path utils

version downloads size

❓ Why

For historical reasons, windows followed MS-DOS and used backslash for separating paths rather than slash used for macOS, Linux, and other Posix operating systems. Nowadays, Windows supports both Slash and Backslash for paths. Node.js's built-in path module in the default operation of the 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 path module will assume that Windows-style paths are being used. This makes inconsistent code behavior between Windows and POSIX.

Compared to popular upath, pathe provides identical exports of Node.js with normalization on all operations and is written in modern ESM/TypeScript and has no dependency on Node.js!

This package is a drop-in replacement of the Node.js's path module module and ensures paths are normalized with slash / and work in environments including Node.js and browsers.

💿 Usage

Install using npm or yarn:

# npm
npm i pathe

# yarn
yarn add pathe

# pnpm
pnpm i pathe

Import:

// ESM / Typescript
import { resolve, matchesGlob } from "pathe";

// CommonJS
const { resolve, matchesGlob } = require("pathe");

Read more about path utils from Node.js documentation and rest assured behavior is consistently like POSIX regardless of your input paths format and running platform (the only exception is delimiter constant export, it will be set to ; on windows platform).

Extra utilities

Pathe exports some extra utilities that do not exist in standard Node.js path module. In order to use them, you can import from pathe/utils subpath:

import { filename, normalizeAliases, resolveAlias, reverseResolveAlias } from "pathe/utils";

License

Made with 💛 Published under the MIT license.

Some code was used from the Node.js project. Glob supported is powered by zeptomatch.

Significant stargazers

btea

299 followers · starred Jan 2025

Corentin Leruth

115 followers · starred Sep 2024

ZHAO Jin-Xiang

417 followers · starred Dec 2024

Mao Mr

95 followers · starred Jun 2023