Skip to content
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

[BUG] npm view --json command returns not only JSON if failed #5444

Closed
2 tasks done
Tracked by #546
ThePlenkov opened this issue Aug 31, 2022 · 4 comments · Fixed by #7508
Closed
2 tasks done
Tracked by #546

[BUG] npm view --json command returns not only JSON if failed #5444

ThePlenkov opened this issue Aug 31, 2022 · 4 comments · Fixed by #7508
Labels
Bug thing that needs fixing config:display Issues dealing with display of data to terminal Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@ThePlenkov
Copy link

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

Use case

I have a monorepo with workspaces. Each workspace gets published to a separate package. In CI pipeline I want to check whether is module needs to be published or no. So to make a central decision which packages I need to publish I would love to know what are the most recent published versions. So what I do I run such a command npm view -ws --json to have a common list of published packages. In case if I add one more package which is not yet published - I get an error npm ERR! 404 Not Found

Expected Behavior

For a single request it makes sense - for a bulk mode - I would prefer to have this error as a part of json payload.

It's ok to have an additional flag to indicate that behavior.

Do you think is possible?

Thank you!

Steps To Reproduce

  1. Create a new monorepo with couple workspaces
  2. Publish them
  3. Add a new workspace
  4. Run npm view -ws --json

Environment

  • npm: 8.12.1
  • Node.js: v18.4.0
@ThePlenkov ThePlenkov 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 31, 2022
@ljharb
Copy link
Collaborator

ljharb commented Aug 31, 2022

Can you try with npm v8.18?

@ThePlenkov
Copy link
Author

of course . Result is same. Actually I thought - it looks like the issue is in view --json command itself. It would be nice if on the error in json mode it would react with json payload, not log

@lukekarrys lukekarrys removed the Needs Triage needs review for next steps label Sep 1, 2022
@lukekarrys
Copy link
Contributor

@ThePlenkov Thanks for the report. I'm tracking a few issues with json output (ref: #4724) and will add this to the list.

Is it ok to recharacterize this issue as only to do with the json payload? I would expect npm -ws to fail as you said if any of the workspaces are missing.

@lukekarrys lukekarrys added config:display Issues dealing with display of data to terminal Priority 2 secondary priority issue labels Sep 1, 2022
@ThePlenkov
Copy link
Author

ThePlenkov commented Sep 2, 2022

@lukekarrys I totally agree. If npm view --json -ws will fail with json containing responses for all workspaces - that would be just perfect! Exit code is correct

@ThePlenkov ThePlenkov changed the title [BUG] npm view for workspaces exits with errors if any of workspaces is not found [BUG] npm view --json command returns not only JSON if failed Sep 2, 2022
lukekarrys added a commit that referenced this issue May 16, 2024
Fixes: #5444

This PR will continue running through all workspaces for `npm view` even
when a workspace encounters an `E404` error. This usually happens when
you run `npm view -ws` but have private workspaces. A future iteration
could log a different message if an `E404` is encountered on a private
workspace, but for this PR I wanted to keep it generic since there are a
number of reasons a request for a package manifest could 404.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing config:display Issues dealing with display of data to terminal Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants