JSPM

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

Normalized paths for Node.js

Package Exports

  • pathe

Readme

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 MSDos and using backslash \\ for seperating paths rather than slash /. While modern versions of Windows as well as Node.js on Windows, support slash nowadays!

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 lots of trouble of different code behavior between Windows and Posix and it makes problems with different behaviors.

This package is a replacement based on built in path module and always ensures path are normalized with slash /.

Compared to popular upath, this package tries to privide identical exports of Node.js with normalization on all operations and written in modern ESM/Typescript (upath is written with coffeescript and is not supporting native esm exports).

๐Ÿ’ฟ 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')

License

MIT