Yarn 4.0.1 brings exciting enhancements, notably with the adoption of Yarn Plug'n'Play (PnP) as the default installation strategy. This replaces the conventional node_modules
folder, offering a more efficient and streamlined dependency management process.
-
Set Yarn to the Latest Stable Version:
yarn set version stable yarn install
-
Configure Yarn to Use Node Modules (Optional):
If you prefer using the traditional
node_modules
folder, execute the following command:yarn config set nodeLinker node-modules
You can use the following command to switch to a different Yarn version:
yarn set version <version>
For example, if you want the latest version, you can run:
yarn set version stable
You can also set it to a specific number, for example:
yarn set version <version_number> // 1.22.19
-
No More
node_modules
:Yarn PnP generates a single Node.js loader file (
.pnp.cjs
) instead of the usualnode_modules
folder. This file encapsulates all information about your project's dependencies. -
Efficient Dependency Tracking:
The loader file informs tools about package locations on the disk, facilitating quick and efficient resolution of
require
andimport
calls.
Yarn PnP is the default installation strategy in modern Yarn releases. While alternative approaches are available, Yarn PnP is recommended for new projects due to its numerous benefits.
Check the official readme for comprehensive details.
Upgrading to Yarn Version 4.0.1 with Yarn PnP streamlines your project's dependency management, enhancing efficiency and providing a more modern development experience. Embrace the future of package management with Yarn!
Feel free to copy and paste this into your README.md file.