# @gatsbyjs/parcel-namer-relative-to-cwd 中文文档

规范地址：https://npmcn.com/package/%40gatsbyjs/parcel-namer-relative-to-cwd/

版本：2\.16\.0
npm 元数据更新时间：2026-06-30T21:59:41.817Z
中文译文更新时间：2026-11-16T00:06:01.769Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40gatsbyjs/parcel-namer-relative-to-cwd
原文对照：https://npmcn.com/package/%40gatsbyjs/parcel-namer-relative-to-cwd/?lang=original
项目主页：https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-parcel-namer-relative-to-cwd#readme
源码仓库：https://github.com/gatsbyjs/gatsby

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

- 包体积（解压后）：16.7 kB，5 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：\>=18\.0\.0 \<26
- 运行依赖：4 个
- 首次发布：2022-03-01T10:28:11.890Z
- 最新版本发布：2026-01-26T20:27:23.237Z
- 近 30 天下载量：785669（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：107（近 12 个月 2 个）

## 中文简介

Parcel 命名器,用于保存目录结构来稳定输出并保持分级.

## 安装

```sh
npm install @gatsbyjs/parcel-namer-relative-to-cwd
```

也可以使用：`pnpm add @gatsbyjs/parcel-namer-relative-to-cwd`、`yarn add @gatsbyjs/parcel-namer-relative-to-cwd`、`bun add @gatsbyjs/parcel-namer-relative-to-cwd`

## README

# `@gatsbyjs/parcel-namer-relative-to-cwd`

这个 [命名器插件](https://parceljs.org/plugin-system/namer/) 用于 [盖茨比](https://www.gatsbyjs.com/) 内部。 你可以在你的应用软件里重新使用它.

如果你只是使用Gatsby,你不需要关心这个包/插件.

## 使用量

```shell
npm install --save-dev @gatsbyjs/parcel-namer-relative-to-cwd
```

在你的内心 `.parcelrc`数字 :

```
{
  "extends": "@parcel/config-default",
  "namers": ["@gatsbyjs/parcel-namer-relative-to-cwd", "..."]
}
```

## 为什么和如何

默认情况下, Parcel 正在试图在受它影响的条目和输出路径之间找到常见/共享目录. 见 [这个问题的评论](https://github.com/parcel-bundler/parcel/issues/5476#issuecomment-769058504) 更多信息.

使用这些输入文件:

```
a.html
sub/b.html
```

你会得到:

-   `parcel build a.html` => `dist/a.html`
-   `parcel build sub/b.html` => `dist/b.html`
-   `parcel build a.html sub/b.html` => `dist/a.html`, (中文(简体) ), `dist/sub/b.html`

看得出来 `sub/b.html` 条目中的任何一项都可能导致 `dist/b.html` 或者说 `dist/sub/b.html` (取决于织物) `a.html` 是否为条目)。 这使得构建不是决定性的,在条目是"可选的"的情况下,这很成问题.

此命名器插件稳定输出, 所以内部 `distDir` 相对于当前工作目录( CWD) , 等级与条目文件相同 :

-   `parcel build a.html` => `dist/a.html`
-   `parcel build sub/b.html` => `dist/sub/b.html`
-   `parcel build a.html sub/b.html` => `dist/a.html`, (中文(简体) ), `dist/sub/b.html`

## 常见问题

### @gatsbyjs/parcel-namer-relative-to-cwd 是什么？

Parcel 命名器,用于保存目录结构来稳定输出并保持分级\.

### 如何安装 @gatsbyjs/parcel-namer-relative-to-cwd？

在项目目录运行 npm install @gatsbyjs/parcel-namer-relative-to-cwd，或使用 pnpm add / yarn add / bun add。

### @gatsbyjs/parcel-namer-relative-to-cwd 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/gatsbyjs\_\_parcel-namer-relative-to-cwd 是否存在。

### @gatsbyjs/parcel-namer-relative-to-cwd 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @gatsbyjs/parcel-namer-relative-to-cwd 需要什么版本的 Node\.js？

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

### @gatsbyjs/parcel-namer-relative-to-cwd 可以商用吗？

@gatsbyjs/parcel-namer-relative-to-cwd 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @gatsbyjs/parcel-namer-relative-to-cwd 的下载量有多少？

根据 npm 官方下载统计，@gatsbyjs/parcel-namer-relative-to-cwd 在 2026/10/16 – 2026/11/14 这 30 天内被下载 785,669 次，日均约 26,189 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @gatsbyjs/parcel-namer-relative-to-cwd 还在维护吗？

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

