-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ls/search) --json arg error also sent to stdout #3437
fix(ls/search) --json arg error also sent to stdout #3437
Conversation
Why would that be something desirable? Errors should never be printed on stdout, and scripts expecting it need correcting. |
We don't have this pattern set up in any of our commands, to my knowledge. If we wanted Leaving this open for now as a reference for a future discussion. |
@wraithgar if errors appear on stdout with |
i think i agree with @ljharb on this one, the behavior in npm 6 was that we hang errors off of the json object and print it as part of the json. npm 7 logging errors in non-json to any stream while printing json feels like a bug (and a regression). |
As discussed at today's open rfc meeting If we were to implement something like this, it would need to be designed from the ground up as a well-defined way to handle errors in If you have a solid idea for how npm should be handling errors (both expected and unexpected) please describe it in an rfc. |
Thank you everyone for taking the time to review it, and thanks for letting me know why it was not accepted. Maybe next time! |
What
Added output to STDOUT via
npm.output()
when:npm search --json
: outputs an error to STDOUT in json format.npm ls --json
& a dependency can't be resolved: the json output to STDOUT has an error embedded.Why
Preserve backwards compatibility for scripts done for 6.x that rely on an error in STDOUT.
References
Fixes #2740