Last active
March 13, 2025 21:30
-
-
Save wojtekmaj/c38351dd715c1b108ab1ab089fcaf6fc to your computer and use it in GitHub Desktop.
How to upgrade Yarn to Yarn Modern (v4 at the moment) seamlessly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.pnp.* | |
.yarn/* | |
!.yarn/patches | |
!.yarn/plugins | |
!.yarn/releases | |
!.yarn/sdks | |
!.yarn/versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Upgrade to latest Yarn Modern (v4 at the moment) | |
# WARNING: If you're running Node.js < 18: | |
# 1. Who hurt you? | |
# 2. Use `yarn set version 3.6.4` instead. | |
yarn set version berry | |
# (optional) Set nodeLinker to node-modules - this 100% guarantees backwards compatibility | |
# NOTE: Not needed in latest Yarn versions, this should be automatic | |
yarn config set nodeLinker node-modules | |
# (optional) Adds `yarn upgrade-interactive` command back | |
# NOTE: Not needed in Yarn v4, plugins are now included | |
yarn plugin import interactive-tools | |
# Reinstalls project using Yarn Modern. This will also update your yarn.lock file, but will | |
# NOT sneakily upgrade the dependencies | |
yarn | |
# Commits the changes | |
git add . && git commit -m "Upgrade Yarn to Yarn Berry" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dominicgan Importing this plugin is no longer necessary in v4. They are now all built in.