JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21971654
  • Score
    100M100P100Q241088F
  • License MIT

Universal path utils

Package Exports

  • pathe

Readme

pathe

Universal 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.

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

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!

💿 Install

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!

License

MIT. Made with 💖

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