# @flex-development/pathe 中文文档

规范地址：https://npmcn.com/package/%40flex-development/pathe/

版本：4\.0\.2
npm 元数据更新时间：2025-05-29T21:45:06.860Z
中文译文更新时间：2026-11-14T22:23:37.529Z
软件包许可：BSD-3-Clause

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40flex-development/pathe
原文对照：https://npmcn.com/package/%40flex-development/pathe/?lang=original
项目主页：https://github.com/flex-development/pathe
源码仓库：https://github.com/flex-development/pathe

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：241 kB，115 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=18\.20\.4
- 运行依赖：4 个
- 首次发布：2022-12-16T07:34:53.060Z
- 最新版本发布：2025-05-29T21:45:06.383Z
- 近 30 天下载量：6072（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：9（近 12 个月 0 个）

## 中文简介

节点通用滴入替换:路径

## 安装

```sh
npm install @flex-development/pathe
```

也可以使用：`pnpm add @flex-development/pathe`、`yarn add @flex-development/pathe`、`bun add @flex-development/pathe`

## README

# 路径

[![github release](https://img.shields.io/github/v/release/flex-development/pathe.svg?include_prereleases&sort=semver)](https://github.com/flex-development/pathe/releases/latest) [![npm](https://img.shields.io/npm/v/@flex-development/pathe.svg)](https://npmjs.com/package/@flex-development/pathe) [![codecov](https://codecov.io/gh/flex-development/pathe/branch/main/graph/badge.svg?token=R2TPEBGWXB)](https://codecov.io/gh/flex-development/pathe) [![license](https://img.shields.io/github/license/flex-development/pathe.svg)](https://npmcn.com/package/%40flex-development/pathe/LICENSE.md) [![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits&logoColor=ffffff)](https://conventionalcommits.org/) [![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript&logoColor=ffffff)](https://typescriptlang.org/) [![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat&logo=vitest&logoColor=ffffff)](https://vitest.dev/) [![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat&logo=yarn&logoColor=ffffff)](https://yarnpkg.com/)

通用空投替换 [`node:path`](https://nodejs.org/api/path.html)

## 目录

-   [这是什么?](https://npmcn.com/package/%40flex-development/pathe/#readme-what-is-this)
-   [我什么时候用这个?](https://npmcn.com/package/%40flex-development/pathe/#readme-when-should-i-use-this)
-   [安装](https://npmcn.com/package/%40flex-development/pathe/#readme-install)
-   [API 密码](https://npmcn.com/package/%40flex-development/pathe/#readme-api)
-   [类型](https://npmcn.com/package/%40flex-development/pathe/#readme-types)
-   [贡献](https://npmcn.com/package/%40flex-development/pathe/#readme-contribute)

## 这是什么?

这个套件是通用的接地来代替Node.js [`path`](https://nodejs.org/api/path.html) 模块.

它执行POSIX和Windows操作系统的一致性,并为工作提供额外的公用事业 有文件 URL、路径和扩展名.

## 我什么时候用这个?

对于 [历史原因](https://learn.microsoft.com/archive/blogs/larryosterman/why-is-the-dos-path-character),Windows跟随MS-DOS并使用回击(`\`) 分离路径 组件,而不是前鞭`/`)被POSIX操作系统所使用. 即使窗口在运行 系统现在支持两个分隔器,操作系统在使用Node.js时仍然存在差异 `path` 模块 :

> 默认操作 `node:path` 模块基于一个 Node.js 应用程序的操作系统而有所不同 运行中。 具体而言,当运行在 Windows 操作系统中时 `node:path` 模块将假设 正在使用 Windows 风格的路径 。 - [_视窗对 POSIX_](https://nodejs.org/api/path.html#windows-vs-posix)

这个软件包通过确保路径符合POSIX来强制操作系统之间的一致性. 支持双方 [驱动](https://learn.microsoft.com/windows/win32/fileio/naming-a-file#naming-conventions) 财务报告和审定财务报表 [UNC 路径](https://learn.microsoft.com/dotnet/standard/io/file-path-formats#unc-paths) 以及平台专用模块,例如: [`node:path/posix`](https://nodejs.org/api/path.html#pathposix) 财务报告和审定财务报表 [`node:path/win32`](https://nodejs.org/api/path.html#pathwin32) 已经不再需要了.

> ~为了在任何操作系统中与 Windows 文件路径合作时取得一致的结果, 使用情况 [`path.win32`](https://nodejs.org/api/path.html#pathwin32)。 。 。 .~ ~为了在任何操作系统上与 POSIX 文件路径合作时取得一致的结果, 使用情况 [`path.posix`](https://nodejs.org/api/path.html#pathposix)。 。 。 .~

**要在任何操作系统中与 Windows 文件路径合作时取得一致的结果, 请使用 `pathe`实现 在任何操作系统中与 POSIX 文件路径合作时, 使用一致的结果 `pathe`. : blush: (中文(简体) )**

## 安装

这个软件包是 [仅限无害环境管理](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)。 。 。 .

在Node.js(第18版+)中与 [线条](https://yarnpkg.com/)数字 :

```sh
yarn add @flex-development/pathe
```

> 见 [Git - 协议QQ Yarn](https://yarnpkg.com/protocol/git)  关于从Git安装的细节.

在德诺与 [`esm.sh`](https://esm.sh/)数字 :

```ts
import { parse } from 'https://esm.sh/@flex-development/pathe'
```

在浏览器中 [`esm.sh`](https://esm.sh/)数字 :

```html
<script type="module">
  import { parse } from 'https://esm.sh/@flex-development/pathe'
</script>
```

## 使用

```ts
import {
  addExt,
  basename,
  changeExt,
  cwd,
  delimiter,
  dirname,
  dot,
  extToValue,
  extname,
  fileURLToPath,
  format,
  formatExt,
  isAbsolute,
  isDeviceRoot,
  isSep,
  isURL,
  join,
  matchesGlob,
  normalize,
  parse,
  pathToFileURL,
  relative,
  removeExt,
  resolve,
  resolveWith,
  root,
  sep,
  toNamespacedPath,
  toPath,
  toPosix
} from '@flex-development/pathe'
```

## API 密码

此套件会导出以下标识符 :

-   [`addExt`](https://npmcn.com/package/%40flex-development/pathe/src/lib/add-ext.mts)
-   [`basename`](https://npmcn.com/package/%40flex-development/pathe/src/lib/basename.mts)
-   [`changeExt`](https://npmcn.com/package/%40flex-development/pathe/src/lib/change-ext.mts)
-   [`cwd`](https://npmcn.com/package/%40flex-development/pathe/src/lib/cwd.mts)
-   [`delimiter`](https://npmcn.com/package/%40flex-development/pathe/src/lib/delimiter.mts)
-   [`dirname`](https://npmcn.com/package/%40flex-development/pathe/src/lib/dirname.mts)
-   [`dot`](https://npmcn.com/package/%40flex-development/pathe/src/lib/dot.mts)
-   [`extToValue`](https://npmcn.com/package/%40flex-development/pathe/src/lib/ext-to-value.mts)
-   [`extname`](https://npmcn.com/package/%40flex-development/pathe/src/lib/extname.mts)
-   [`extnames`](https://npmcn.com/package/%40flex-development/pathe/src/lib/extnames.mts)
-   [`fileURLToPath`](https://npmcn.com/package/%40flex-development/pathe/src/lib/file-url-to-path.mts)
-   [`formatExt`](https://npmcn.com/package/%40flex-development/pathe/src/lib/format-ext.mts)
-   [`format`](https://npmcn.com/package/%40flex-development/pathe/src/lib/format.mts)
-   [`isAbsolute`](https://npmcn.com/package/%40flex-development/pathe/src/lib/is-absolute.mts)
-   [`isDeviceRoot`](https://npmcn.com/package/%40flex-development/pathe/src/lib/is-device-root.mts)
-   [`isSep`](https://npmcn.com/package/%40flex-development/pathe/src/lib/is-sep.mts)
-   [`isURL`](https://npmcn.com/package/%40flex-development/pathe/src/lib/is-url.mts)
-   [`join`](https://npmcn.com/package/%40flex-development/pathe/src/lib/join.mts)
-   [`matchesGlob`](https://npmcn.com/package/%40flex-development/pathe/src/lib/matches-glob.mts)
-   [`normalize`](https://npmcn.com/package/%40flex-development/pathe/src/lib/normalize.mts)
-   [`parse`](https://npmcn.com/package/%40flex-development/pathe/src/lib/parse.mts)
-   [`pathToFileURL`](https://npmcn.com/package/%40flex-development/pathe/src/lib/path-to-file-url.mts)
-   [`posix`](https://npmcn.com/package/%40flex-development/pathe/src/pathe.mts)
-   [`relative`](https://npmcn.com/package/%40flex-development/pathe/src/lib/relative.mts)
-   [`removeExt`](https://npmcn.com/package/%40flex-development/pathe/src/lib/remove-ext.mts)
-   [`resolveWith`](https://npmcn.com/package/%40flex-development/pathe/src/lib/resolve-with.mts)
-   [`resolve`](https://npmcn.com/package/%40flex-development/pathe/src/lib/resolve.mts)
-   [`root`](https://npmcn.com/package/%40flex-development/pathe/src/lib/root.mts)
-   [`sep`](https://npmcn.com/package/%40flex-development/pathe/src/lib/sep.mts)
-   [`toNamespacedPath`](https://npmcn.com/package/%40flex-development/pathe/src/lib/to-namespaced-path.mts)
-   [`toPath`](https://npmcn.com/package/%40flex-development/pathe/src/lib/to-path.mts)
-   [`toPosix`](https://npmcn.com/package/%40flex-development/pathe/src/lib/to-posix.mts)
-   [`win32`](https://npmcn.com/package/%40flex-development/pathe/src/pathe.mts)

默认导出为 `pathe`。 。 。 .

> 文件网站即将到来.

## 类型

此软件包已全部输入 [类型脚本](https://www.typescriptlang.org/)。 。 。 .

-   [`Cwd`](https://npmcn.com/package/%40flex-development/pathe/src/types/cwd.mts)
-   [`Delimiter`](https://npmcn.com/package/%40flex-development/pathe/src/types/delimiter.mts)
-   [`DeviceRoot`](https://npmcn.com/package/%40flex-development/pathe/src/types/device-root.mts)
-   [`Dot`](https://npmcn.com/package/%40flex-development/pathe/src/types/dot.mts)
-   [`DriveLetter`](https://npmcn.com/package/%40flex-development/pathe/src/types/drive-letter.mts)
-   [`EmptyString`](https://npmcn.com/package/%40flex-development/pathe/src/types/empty-string.mts)
-   [`Ext`](https://npmcn.com/package/%40flex-development/pathe/src/types/ext.mts)
-   [`FormatInputPathObject`](https://npmcn.com/package/%40flex-development/pathe/src/interfaces/format-input-path-object.mts)
-   [`ParsedPath`](https://npmcn.com/package/%40flex-development/pathe/src/interfaces/parsed-path.mts)
-   [`Pathe`](https://npmcn.com/package/%40flex-development/pathe/src/interfaces/pathe.mts)
-   [`PlatformOptions`](https://npmcn.com/package/%40flex-development/pathe/src/interfaces/platform-options.mts)
-   [`PlatformPath`](https://npmcn.com/package/%40flex-development/pathe/src/interfaces/platform-path.mts)
-   [`PosixDelimiter`](https://npmcn.com/package/%40flex-development/pathe/src/types/delimiter-posix.mts)
-   [`PosixPlatformPath`](https://npmcn.com/package/%40flex-development/pathe/src/interfaces/platform-path-posix.mts)
-   [`PosixSep`](https://npmcn.com/package/%40flex-development/pathe/src/types/sep-posix.mts)
-   [`Sep`](https://npmcn.com/package/%40flex-development/pathe/src/types/sep.mts)
-   [`WindowsDelimiter`](https://npmcn.com/package/%40flex-development/pathe/src/types/delimiter-windows.mts)
-   [`WindowsPlatformPath`](https://npmcn.com/package/%40flex-development/pathe/src/interfaces/platform-path-windows.mts)
-   [`WindowsSep`](https://npmcn.com/package/%40flex-development/pathe/src/types/sep-windows.mts)

## 贡献

见 [`CONTRIBUTING.md`](https://npmcn.com/package/%40flex-development/pathe/CONTRIBUTING.md)。 。 。 .

这个项目有一个 [行为守则](https://npmcn.com/package/%40flex-development/pathe/CODE_OF_CONDUCT.md)通过与该存储库、组织或 你同意遵守它的规定.

## 常见问题

### @flex-development/pathe 是什么？

节点通用滴入替换:路径

### 如何安装 @flex-development/pathe？

在项目目录运行 npm install @flex-development/pathe，或使用 pnpm add / yarn add / bun add。

### @flex-development/pathe 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @flex-development/pathe 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @flex-development/pathe 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18\.20\.4。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @flex-development/pathe 可以商用吗？

@flex-development/pathe 使用 BSD-3-Clause 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括，不构成法律意见，请以许可原文为准。

### @flex-development/pathe 的下载量有多少？

根据 npm 官方下载统计，@flex-development/pathe 在 2026/10/15 – 2026/11/13 这 30 天内被下载 6,072 次，日均约 202 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @flex-development/pathe 还在维护吗？

最新版本 4\.0\.2 发布于 2025/05/30（1\.5 年前）；至今共发布 9 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/12/16。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

