Skip to content

Percy does not work with Yarn PnP #1612

Description

@wojtekmaj

The problem

[percy] Error: @percy/cli-exec tried to access @percy/client, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @percy/client (via "@percy/client/utils")
Required by: @percy/cli-exec@npm:1.28.7 (via /Users/wmaj/.yarn/berry/cache/@percy-cli-exec-npm-1.28.7-55645a8ef5-10c0.zip/node_modules/@percy/cli-exec/dist/exec.js)

…followed by a couple more similar errors.

Environment

  • Node version: 22.0.0
  • @percy/cli version: 1.28.7
  • Version of Percy SDK you’re using: ?
  • If needed, a build or snapshot ID: ?
  • OS version: macOS 14.5 (23F79)
  • Type of shell command-line [interface]: zsh

Details

The error described above appears when percy exec command is attempted from Yarn Plug'n'Play, which is treating wrong/missing dependencies more strictly than other package managers. While this error appears on Yarn only, it signifies a deeper issue that other users of other package managers might encounter.

Adding the following to yarnrc.yml:

packageExtensions:
  '@percy/cli-exec@*':
    dependencies:
      '@percy/client': '*'
  '@percy/playwright@*':
    dependencies:
      '@percy/sdk-utils': '*'
    peerDependencies:
      playwright: '*'

fixes the issue, but it shouldn't be necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions