Upgrading

Manual Upgrade

All Modern.js official packages are released with a uniform version number, so when upgrading, you need to update all @modern-js/** packages to the target version uniformly.

Upgrade Steps

  1. Check the latest version

    You can check the latest version of Modern.js through the following methods:

    According to the Release Note on the official website, developers can also manually upgrade the project to the desired version.

  2. Update package.json

    In the project's package.json, update all @modern-js/** packages to the target version. For example:

    package.json
    {
      "dependencies": {
        "@modern-js/app-tools": "3.0.0",
        "@modern-js/runtime": "3.0.0"
      },
      "devDependencies": {
        "@modern-js/types": "3.0.0"
      }
    }
  3. Reinstall dependencies

    After updating package.json, reinstall dependencies:

    npm
    yarn
    pnpm
    bun
    deno
    npm install
Tip

When upgrading, you need to upgrade all packages provided by Modern.js uniformly, rather than upgrading individual dependencies. Ensure that all @modern-js/** packages have the same version number.

Version Management Strategy

In Modern.js projects, we recommend that all officially provided dependencies use fixed version, and avoid using ^ or ~ for range declarations. For example:

{
  "dependencies": {
    "@modern-js/app-tools": "x.y.z"
  }
}

This ensures that the versions of dependencies are fully determined, thereby guaranteeing build consistency and predictability.

Lock nested dependency

When a nested dependency of the project has a problem and Modern.js cannot be updated immediately, you can use the package manager to lock the version of the nested dependency.

pnpm

For projects using pnpm, add the following configuration to the package.json in the root directory of the project, and then run pnpm install again:

package.json
{
  "pnpm": {
    "overrides": {
      "package-name": "^1.0.0"
    }
  }
}

Yarn

For projects using Yarn, add the following configuration to the package.json in the root directory of the project, and then run yarn install again:

package.json
{
  "resolutions": {
    "package-name": "^1.0.0"
  }
}

Npm

For projects using Npm, add the following configuration to the package.json in the root directory of the project, and then run npm install again:

package.json
{
  "overrides": {
    "package-name": "^1.0.0"
  }
}
Info

For Monorepo repositories, you can only lock dependency versions in the package.json in the root directory of the project, and it will affect all packages in the Monorepo.