Repository navigation
Yarn PnP Support Status #16980
Description
With the release of Yarn 2.0, many users may be interested in trying out the new version of the package manager with the Angular CLI. As of 9.0, the Angular CLI does not natively support Yarn 2.0 and its new package management strategy named Plug’n’Play (PnP). However, native support is currently and actively being investigated with several initial steps already in place. Native support is tentatively scheduled for inclusion in 10.0 or beyond with the goal of integrating new major versions of upstream dependencies that provide native support.
For those that are interested in experimenting with building applications using the new package manager, you can use the following instructions to workaround the current issues.
WARNING: This is not recommended for use with deployed applications and should not be used in a production environment.
- Install the workspace dependencies using Yarn 2.0
- Install the
pnpifypackage:yarn add -D @yarnpkg/pnpify - Unplug all Angular related packages including third-party libraries used within the application via
yarn unplug <package_name>. This should include at a minimum all@angularscoped packages. - If using the E2E command, the
webdriver-managerpackage also needs to be unplugged:yarn unplug webdriver-manager
Once these steps are complete, Angular CLI operations such as serve or build can be used by executing yarn pnpify ng build or yarn pnpify ng serve, respectively.
Please note that manually running the ngcc command with or without the pnpify utility does not currently work.
If any issues are encountered using the workaround steps or for Yarn 2.0 in general, please open a separate issue detailing the problem.
Activity
[-]Yarn PnP Support Status[/-][+]Yarn 2.0 Support Status[/+]larixer commentedon Feb 15, 2020
Another way of making Angular 9 work with Yarn 2.0 is to use
nodeLinker: node-modulesin<project_root>/.yarnrc.yml, this will usenode_modulesscheme for installation.Yarn team is investing into
node_modulessupport and trying to make it work better than it was in Yarn 1.x, but the future is definitely not withnode_modules.andreialecu commentedon Feb 25, 2020
Some possibly relevant information regarding improving yarn 2.0 support:
#14841 (comment)
Replacing
read-package-treewith acreateRequireimplementation might be a first step in that direction. The comment above links to a PR ingatsbywhere they did something similar.I noticed that @clydin authored most of the code in that file, perhaps #14841 could be fixed in the process as well.
Langstra commentedon Jul 11, 2020
How does 2.1 with node_modules linker improvements impact this issue?
https://dev.to/arcanis/yarn-2-1-git-workspaces-focused-installs-loose-mode-live-playground-4kfc
https://yarnpkg.com/configuration/yarnrc#nodeLinker
klemenoslaj commentedon Sep 13, 2020
With
nodeLinkerconfigured tonode_modulesI was able to migrate a small Angular CLI project without a single issue, with zero installs configuration even.ronnyek commentedon Oct 6, 2020
I'm not suggesting it would be trivial to fix this and have it automatically work the way yarn 2 works by default out of box, in addition to continuing to support NPM... but I would say this would probably go a long ways to improve developer experience.
Can't wait until node_modules (at least the way it works today) is a thing of the past.
andreialecu commentedon Oct 6, 2020
There is ongoing work right now in
@angularcore packages to rework things in a way that would allow Yarn2+PnP to work natively.You can read more and track the progress here: angular/angular#38099
krokofant commentedon Dec 27, 2020
Since the above linked issue was closed we can track the progress here https://github.com/orgs/angular/projects/2
140 remaining items
michaelfaith commentedon Nov 27, 2023
Similar issue with me. I feel like this should be reported as a new bug. Would you agree?
ld210 commentedon Dec 1, 2023
Absolutely, thank you !
demurgos commentedon Jan 9, 2024
As of Angular 17.0.8, I can run it with Yarn 4.0.2 PnP with the following config in
.yarnrc.yml:The main issue seem to be misconfigured package that forget some dependencies.
demurgos commentedon Feb 9, 2024
Regarding my previous comment: it works for the older Webpack builder, but I'm now trying to move to the new esbuild builder and I get a bunch of import errors☹️
borgez commentedon Feb 10, 2024
try to clear cache .angular, when change pnp\node-modules for me it helps
pkurcx commentedon Aug 6, 2024
How it is going?
alexeagle commentedon Mar 26, 2025
It seems we'll use this issue for pnpm as well.
Bazel compatibility requires
hoist=falsein.npmrc(https://pnpm.io/npmrc#hoist)which is essentially the same strictness semantics as Yarn PnP
I have to add this to
package.jsonto workaround a missing dep:fix: add missing peerDep
fix: add missing peerDep
ld210 commentedon Apr 7, 2025
So, it's been a few years since we made the change to PnP. So far, it is working great. There is still some pain points, but I don't know if it is an Angular issue or a Yarn issue. So here it is:
yarn ng update @angular/cli @angular/corestill doesn't work. I still have to opt out of pnp mode and revert to node_modules before i can update Angular's packages. Not a big issue, but it complicates things, and it isn't easy to document. That's the main pain point in my opinion, which is not that big of a deal. It's just not as comfortable.There is a new issue since I update to Angular 19: I have to regularly remove the angular cache before
yarn ng serve, because of a weird error (unable to find some packages, i will post the full message when I'll deal with this error again)All in all, the benefits of PnP far outweigh those painpoints.
pkurcx commentedon Apr 7, 2025
I've started using bun as it works the same way npm does but it is much faster
fix: add missing peerDep
ld210 commentedon Sep 2, 2025
Hi all,
a little update: so, I've just upgraded Angular to v20. Things seems to work way better, I don't have to register "ghosts dependencies" in .yarnrc.yml file anymore, which is good.
But, I stumbled upon an error that I never had previously. Before updating Angular packages, I updated my node version to 22.12.0 (previously 18.20.6) following version compatibility chart (https://angular.dev/reference/versions).
After upgrading all dependencies, I had this error :
an unhandled exception occurred: cannot find package 'chalk'Depending on what I did to try to fix this, the offending package changes (Ora, Yargs).
The only thing that worked was to update nodejs to v24. I tried 20.19.0, same errors. Only node 24 will work with Angular 20 in PnP mode in our project.
alan-agius4 commentedon Aug 26, 2026
Thanks for reporting this issue. Luckily, it has already been fixed in one of the recent releases. Please update to the most recent version to resolve the problem.
If the problem persists in your application after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. You can use
ng new repro-appto create a new project where you reproduce the problem.