Skip to content

Angular 20 fails to start with yarn pnp (up to version 18 it was working) #30847

@pwilkowski

Description

@pwilkowski

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

15,16,17,18

Description

When using nodeLinker: pnp for yarn, angular refuses to start throwing errors like those:

Unknown error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'yargs-parser' imported from \angular20.yarn\unplugged\yargs-npm-18.0.0-ec82bf7b61\node_modules\yargs\helpers\helpers.mjs

I did check and yargs seem to work in raw project with PNP enabled so there is something angular specific.

Minimal Reproduction

need to use yarn as package manager

  1. ng new (making sure to create version 20)
  2. yarn set version berry (this should set "packageManager": "yarn@4.9.2")
  3. in file .yarnrc.yml place nodeLinker: pnp
  4. yarn start

Exception or Error

Unknown error: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'yargs-parser' imported from \angular20\.yarn\unplugged\yargs-npm-18.0.0-ec82bf7b61\node_modules\yargs\helpers\helpers.mjs

Your Environment

Angular CLI: 20.1.5
Node: 22.14.0
Package Manager: yarn 4.9.2
OS: win32 x64

Angular: 20.1.6
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2001.5
@angular-devkit/core         20.1.5
@angular-devkit/schematics   20.1.5
@angular/build               20.1.5
@angular/cli                 20.1.5
@schematics/angular          20.1.5
rxjs                         7.8.2
typescript                   5.8.3

Anything else relevant?

It seems that there is some friction between angular cli and yargs
adding yargs and yargs-parser to dependencies does nothing
unplugging both of those packages does nothing.

we have been using angular since version 14 updating regularly but 20 is major regression in this regard.

I tried to create minimal repo with yarn pnp and just yargs, yargs-parser and it seem to work just fine:

{
	"name": "yargs-test",
	"packageManager": "yarn@4.9.2",
	"type": "module",
	"scripts": {
		"test": "node index.js"
	},
	"dependencies": {
		"yargs": "^18.0.0",
		"yargs-parser": "^22.0.0"
	}
}

Only the angular seem to fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions