Skip to content

guide yarn 2 support

devonfw-core edited this page Nov 30, 2021 · 5 revisions

Yarn 2

Yarn v2 is a very different software from the v1. The following list contains the main new features:

Please, read them carefully to decide if your current project is suitable to use Yarn 2 as package manager.

Some features are still experimental, so please do not use them in production environments.

More info at https://yarnpkg.com/

Global Install

Installing Yarn 2.x globally is discouraged as Yarn team is moving to a per-project install strategy. We advise you to keep Yarn 1.x (Classic) as your global binary by installing it via the instructions you can find here.

Once you’ve followed the instructions (running yarn --version from your home directory should yield something like 1.22.0), go to the next section to see how to enable Yarn 2 on your project.

Per-project install

Follow these instructions to update your current devon4ng project to Yarn 2:

  1. Follow the global install instructions.

  2. Move into your project folder:

    cd ~/path/to/project
  3. Run the following command:

    yarn policies set-version berry # below v1.22
    yarn set version berry          # on v1.22+
  4. Since Angular CLI still is not fully supported with the new Yarn architecture as it is not compatible with PnP it is necessary to include the node-modules plugin adding the following line in the .yarnrc.yml file:

    nodeLinker: node-modules
  5. Commit the .yarn and .yarnrc.yml changes

  6. Run again yarn install.

ℹ️
For more advanced migration topics please refer to https://yarnpkg.com/advanced/migration

Which files should be added to gitignore file?

If you’re using Zero-Installs:

.yarn/*
!.yarn/cache
!.yarn/releases
!.yarn/plugins

If you’re not using Zero-Installs:

.yarn/*
!.yarn/releases
!.yarn/plugins
.pnp.*
Clone this wiki locally