Skip to content

pnpm ls --json must not show errors #7514

@rentalhost

Description

@rentalhost

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

8.14.1

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

  • Initialize package.json with some package;
  • Create a file .npmrc containing invalid data;
  • Run pnpm ls --json;

Example .npmrc: (it fails on Windows, at least.)

@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=${FONTAWESOME_TOKEN}

Describe the Bug

When you run pnpm ls --json it will show a WARN on top like:

 WARN  Issue while reading "./.npmrc". Failed to replace env in config: ${FONTAWESOME_TOKEN}

And because of that, JSON cannot be parsed directly from stdout. Maybe this WARN should be stderr, but it goes to stdout together with JSON.

Expected Behavior

pnpm ls --json must not thrown warn, or maybe we need an option to disable it, like pnpm ls --json --warn=0.

Which Node.js version are you using?

20.10.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions