Skip to content

[Bug?]: Inaccurate error messaging for non-JSON-compliant package.json file #7013

@whorvath2

Description

@whorvath2

Self-service

  • I'd be willing to implement a fix

Describe the bug

When package.json is accidentally left in a state that's not JSON-compliant (e.g., a comma is left after the last element in a list) and a yarn command is run against that package, the error received is Error executing command: Failed to get yarn version. While technically accurate, this isn't terribly useful and is arguably misleading, especially for less experienced developers.

To reproduce

  1. Create a minimal package.json file.
  2. Intentionally introduce an error in the file that makes it incompatible with the JSON standard.
  3. Save the file.
  4. Run yarn install

Environment

System:
    OS: macOS 26.1
    CPU: (10) arm64 Apple M1 Max
  Binaries:
    Node: 22.21.0 - /private/var/folders/gy/11s_g2bx3cz3d13rp_j0qjzw0000gr/T/xfs-4969a028/node
    Yarn: 4.12.0 - /private/var/folders/gy/11s_g2bx3cz3d13rp_j0qjzw0000gr/T/xfs-4969a028/yarn
    npm: 10.9.4 - /Users/bhorvath/.nvm/versions/node/v22.21.0/bin/npm

Additional context

It's kinda ironic that, if I hadn't been able to diagnose this problem, I couldn't have filled in the Environment field by following the instructions. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions