Skip to content

[Bug?]: Cannot easily test for yarn install warnings in CI when using esm modules with pnp #7066

@NormalGaussian

Description

@NormalGaussian

Self-service

  • I'd be willing to implement a fix

Describe the bug

I want to be able to have a CI step that checks there are no warnings in my yarn environment; however using esm and pnp creates a warning I cannot suppress or filter out. This makes it particularly complex to detect issues.

Specifically: when a project uses ESM (type: "module" or has ESM dependencies), yarn install emits:

➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: · Done with warnings in 0s 508ms

There appears to be no way to detect or filter this:

  1. logFilters cannot filter it: The warning uses message code YN0000 (MessageName.UNNAMED). The log filter implementation explicitly bypasses code 0: if(C===null||C===0) return x skips all text/pattern/code matching and returns the default level. This is tracked in [Bug?]: yarn 4 logFilters is unable to filter most messages #6221.

2. No structured output: yarn install does not support --json, so there's no machine-readable way to parse warnings from output.

  1. No non-zero exit code: exitCode() only checks this.errorCount > 0. warningCount only changes the "Done with warnings" text but the process exits 0.

  2. The warning itself is unavoidable: As described in [Bug?]: Implicit behaviour of pnpEnableEsmLoader: false is not documented or communicated #5747, pnpEnableEsmLoader is implicitly enabled when any dependency uses type: "module", regardless of the config defaulting to false. Setting it explicitly to false would disable ESM support, which isn't viable.

The result is that CI pipelines cannot treat warnings as failures (to catch real issues), without catching known-harmless warnings

To reproduce

package.json:

{
  "name": "example",
  "packageManager": "yarn@4.13.0",
  "type": "module",
  "dependencies": {
    "cowsay": "^1.6.0"
  }
}

.yarnrc.yml:

nodeLinker: pnp
logFilters:
  - code: YN0000
    text: "ESM support for PnP uses the experimental loader API and is therefore experimental"
    level: discard

Then run yarn install

Environment

System:
    OS: Linux 6.8 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
    CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
  Binaries:
    Node: 25.6.1 - /tmp/xfs-96160961/node
    Yarn: 4.13.0 - /tmp/xfs-96160961/yarn
    npm: 11.9.0 - /home/redacted/.nvm/versions/node/v25.6.1/bin/npm
    bun: 1.3.9 - /home/redacted/.bun/bin/bun
    Deno: 2.5.6 - /home/redacted/.deno/bin/deno

Additional context

I'd happily produce a fix for this; but its quite unclear what would be accepted.

Filtering YN0000 seems against an existing policy; adding --json to install with a {warnings:[]} that can be filtered with jq seems like a very large change; removing the warning seems possible, but may be contentious

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwaiting for feedbackWill autoclose in a while unless more data are provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions