Upgrading
Upgrading to 2.0
Update turbo.json
Get started upgrading from 1.x to 2.0 by running:
This will update your turbo.json(s) for many of the breaking changes from 1.x to 2.0.
Additionally, a name field will be added to any package.json in the Workspace that doesn't have one.
Good to know:
You may also manually run each codemod individually. Visit the codemods page for more information.
Add a packageManager field to root package.json
The packageManager field is a convention from the Node.js ecosystem that defines which package manager is expected to be used in the Workspace.
Turborepo 2.0 requires that your Workspace define this field as a way to improve the stability and behavioral predictability of your codebase. If you do not have one already, add this field to your root package.json:
Update eslint-config-turbo
eslint-config-turbo helps identify environment variables that need to be added to the env key for caching. If you're using it, make sure you update it to match your major version.
Update turbo run commands
Turborepo 2.0 includes behavioral and correctness improvements with behavior of turbo run commands. Listed below is the summary of changes, which may or may not have an affect on your codebase:
- Strict Mode for environment variables is now the default, moving from Loose Mode (PR)
- If it appears that the scripts in your tasks are missing environment variables, you can opt back out of this behavior using the
--env-modeoption on a per-command basis to incrementally migrate. We encourage you to update theenvkey in your task to account for all of its environment variables so you can drop the--env-modeoption as soon as possible. - If you'd like to set the default for the repository back to Loose Mode, you can do so using the
envModeconfiguration.
- If it appears that the scripts in your tasks are missing environment variables, you can opt back out of this behavior using the
- Workspace root directory is now an implicit dependency of all packages (PR)
- The repository should have as little code in the root as possible, since changes to the root can affect all tasks in your repository. Additionally, if you're using Internal Packages in the Workspace root, changes to those dependencies will also cause cache misses for all tasks. In both cases, consider moving the code out of the root and into a package.
--ignoreremoved in favor of--filterand graph correctness changes below (PR)- Removed
--scopeflag (deprecated since 1.2) (PR) enginesfield in rootpackage.jsonis now used in hashing (PR)--filterno longer infers namespaces for package names (PR)--filternow errors when no package names or directories are matched (PR)--onlyrestricts task dependencies instead of package dependencies (PR)