# Discourse core 正在切换到 pnpm 进行 JS 包管理

**URL:** https://meta.discourse.org/t/discourse-core-is-switching-to-pnpm-for-js-package-management/324521
**Category:** Development
**Tags:** dev-news
**Created:** [2024年九月3日 09:26 UTC](https://meta.discourse.org/t/discourse-core-is-switching-to-pnpm-for-js-package-management/324521 "2024-09-03T09:26:41Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2024年九月3日 09:26 UTC](https://meta.discourse.org/t/discourse-core-is-switching-to-pnpm-for-js-package-management/324521/1 "2024-09-03T09:26:41Z")

</div>

我们将 Discourse core 的 JS 包管理器从 [‘yarn classic’](https://classic.yarnpkg.com/) 切换到 [pnpm](https://pnpm.io/)。这将显著提高安装速度和存储要求。

## Production

如果您使用托管服务或标准安装，则无需执行任何操作。更改将在您下次更新时自动应用。

如果您有自定义的生产环境，则需要将所有 `yarn ...` 命令更改为 `pnpm ...`。

## Development

拉取 Discourse core 的最新版本后，在启动服务器时可能会看到类似以下的错误：

```plaintext
pnpm is not installed

```

或者，如果您运行 `yarn install` 等命令，您会看到：

```markdown
error discourse@: The engine "yarn" is incompatible with this module. Expected version "please-use-pnpm". Got "..."

```

要解决此问题，您应该：

1. 运行 `npm install -g pnpm`
2. 运行 `pnpm install`
3. 将开发环境中的所有 `yarn ...` 用法替换为 `pnpm ...`

## Plugins / Themes

我们已将官方插件/主题切换为使用 `pnpm` 来处理其 linting 依赖项。

对于 [`discourse_theme` CLI](https://meta.discourse.org/t/install-the-discourse-theme-cli-console-app-to-help-you-build-themes/82950)，您需要通过运行 `gem update discourse_theme` 来更新本地版本。

## 切换回 `yarn`

如果您需要切换回基于 `yarn` 的 Discourse 版本（例如，在 stable 分支上进行开发），则需要手动删除 core 的所有 node\_modules 目录：

```plaintext
rm -rf node_modules app/assets/javascripts/*/node_modules

```

---

_[View the full topic](https://meta.discourse.org/t/discourse-core-is-switching-to-pnpm-for-js-package-management/324521)._
