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.
Check the latest version
You can check the latest version of Modern.js through the following methods:
@modern-js/app-toolsAccording to the Release Note on the official website, developers can also manually upgrade the project to the desired version.
Update package.json
In the project's package.json, update all @modern-js/** packages to the target version. For example:
{
"dependencies": {
"@modern-js/app-tools": "3.0.0",
"@modern-js/runtime": "3.0.0"
},
"devDependencies": {
"@modern-js/types": "3.0.0"
}
}Reinstall dependencies
After updating package.json, reinstall dependencies:
npm install
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.
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.
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.
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:
{
"pnpm": {
"overrides": {
"package-name": "^1.0.0"
}
}
}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:
{
"resolutions": {
"package-name": "^1.0.0"
}
}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:
{
"overrides": {
"package-name": "^1.0.0"
}
}
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.