Skip to main content

升级 Strapi 版本

¥Upgrade Strapi version

Strapi 通过升级定期发布代码改进。升级不包含重大更改,并在终端和管理面板中宣布。每当新的 Strapi 版本包含重大更改时,就会提供 迁移指南

¥Strapi periodically releases code improvements through upgrades. Upgrades contain no breaking changes and are announced in both the terminal and in the administration panel. Migration guides are provided whenever a new Strapi version includes breaking changes.

提醒

创建自定义代码或修改现有代码的 插件扩展 将需要更新并与存储库中的更改进行比较。不更新插件扩展可能会破坏应用。

¥Plugins extension that create custom code or modify existing code will need to be updated and compared to the changes in the repository. Not updating the plugin extensions could break the application.

升级依赖

¥Upgrade the dependencies

☑️ Prerequisites
  • 开始升级之前停止服务器。

    ¥Stop the server before starting the upgrade.

  • 确认当前 Strapi 版本与最终 Strapi 版本之间不存在 migrations

    ¥Confirm there are no migrations between the current and ultimate Strapi versions.

  1. package.json 中的所有 Strapi 软件包版本号升级到最新的稳定 Strapi 版本(Strapi 稳定版本列在 GitHub 发布页面 上):

    ¥Upgrade all of the Strapi packages version numbers in package.json to the latest stable Strapi version (Strapi stable versions are listed on the GitHub releases page):

    // path: package.json

    {
    // ...
    "dependencies": {
    "@strapi/strapi": "4.7.0",
    "@strapi/plugin-users-permissions": "4.7.0",
    "@strapi/plugin-i18n": "4.7.0",
    "better-sqlite3": "7.4.6"
    // ...
    }
    }

  2. 保存编辑后的 package.json 文件。

    ¥Save the edited package.json file.

  3. 安装升级版本:

    ¥Install the upgraded version:

    yarn
    💡 提示

    如果该操作不起作用,请尝试删除 yarn.lockpackage-lock.json。如果这不起作用,请同时删除 node_modules 文件夹,然后重试。

    ¥If the operation doesn't work, try removing your yarn.lock or package-lock.json. If that doesn't help, remove the node_modules folder as well and try again.

重建应用

¥Rebuild the application

在项目根目录中运行以下命令来重建 Strapi 的管理面板:

¥Run the following command in your project root directory to rebuild Strapi's admin panel:

yarn build

重新启动应用

¥Restart the application

在项目根目录中运行以下命令来重新启动应用:

¥Run the following command in your project root directory to restart the application:

yarn develop