pathe
Normalized paths for Node.js
Last updated 3 years ago by pi0 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install pathe 
SYNC missed versions from official npm registry.

🛣️ pathe

Universal filesystem path utils

version downloads size

❓ Why

For historical reasons, windows followed MS-DOS and using 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 is providing identical exports of Node.js with normalization on all operations and 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.

💿 Usage

Install using npm or yarn:

# npm
npm i pathe

# yarn
yarn add pathe

# pnpm
pnpm i pathe

Import:

// ESM / Typescript
import { resolve } from 'pathe'

// CommonJS
const { resolve } = require('pathe')

Read more about path utils from Node.js documentation and rest assured behavior is ALWAYS like POSIX regardless of your input paths format and running platform!

Extra utilties

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 } from 'pathe/utils'

License

MIT. Made with 💖

Some code used from Node.js project. See LICENSE.

Current Tags

  • 1.1.2                                ...           latest (10 months ago)

21 Versions

  • 1.1.2                                ...           10 months ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.3.9                                ...           2 years ago
  • 0.3.8                                ...           2 years ago
  • 0.3.7                                ...           2 years ago
  • 0.3.6                                ...           2 years ago
  • 0.3.5                                ...           2 years ago
  • 0.3.4                                ...           2 years ago
  • 0.3.3                                ...           2 years ago
  • 0.3.2                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
  • 0.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Total 3
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (6)

© 2010 - cnpmjs.org x YWFE | Home | YWFE