Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] npm show --json outputs to stderr instead of stdout when registry responds with 404 #5286

Closed
2 tasks done
ahmadnassri opened this issue Aug 10, 2022 · 1 comment
Closed
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release

Comments

@ahmadnassri
Copy link

ahmadnassri commented Aug 10, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

run any command with --json and a 404 response:

$ npm --json show foobar@0.0.0 2> stderr.txt 1> stdout.txt

all the content is on stderr:

$ cat stderr.txt
npm ERR! code E404
npm ERR! 404 No match found for version 0.0.0
npm ERR! 404 
npm ERR! 404  'foobar@0.0.0' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
{
  "error": {
    "code": "E404",
    "summary": "No match found for version 0.0.0",
    "detail": "\n 'foobar@0.0.0' is not in this registry.\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
  }
}

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ahmad/.npm/_logs/2022-08-10T02_39_53_304Z-debug-0.log

empty result on stdout:

$ cat stdout.txt

Expected Behavior

the json object should be written to stdout:

$ npm --json show foobar@0.0.0 2> stderr.txt 1> stdout.txt
$ cat stderr.txt
npm ERR! code E404
npm ERR! 404 No match found for version 0.0.0
npm ERR! 404 
npm ERR! 404  'foobar@0.0.0' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ahmad/.npm/_logs/2022-08-10T02_39_53_304Z-debug-0.log
$ cat stdout.txt

{
  "error": {
    "code": "E404",
    "summary": "No match found for version 0.0.0",
    "detail": "\n 'foobar@0.0.0' is not in this registry.\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
  }
}

Steps To Reproduce

see above

Environment

  • npm: 8.15.0
@ahmadnassri ahmadnassri added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Aug 10, 2022
ahmadnassri pushed a commit to ahmadnassri/node-updated that referenced this issue Aug 10, 2022
@wraithgar
Copy link
Member

This was originally brought up in #2740 and has an ongoing discussion in #4724.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants