2.4 KiB
pathe
Normalized paths for Node.js
🧪 This package is still experimental and might not handle all cases. Please track issues.
❓ 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 /
.
Compared to popular upath, pathe is providing identical exports of Node.js with normalization on all operations and written in modern ESM/Typescript.
💿 Install
Install using npm or yarn:
npm i pathe
# or
yarn add 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.