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 ls --omit=dev does not omit dev dependencies #4739

Closed
2 tasks done
denik1981 opened this issue Apr 12, 2022 · 4 comments · Fixed by #4744
Closed
2 tasks done

[BUG] npm ls --omit=dev does not omit dev dependencies #4739

denik1981 opened this issue Apr 12, 2022 · 4 comments · Fixed by #4744
Labels
Bug thing that needs fixing cmd:list related to `npm list` Priority 1 high priority issue Release 8.x work is associated with a specific npm 8 release

Comments

@denik1981
Copy link

denik1981 commented Apr 12, 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

npm ls --help does not show --prod between the list of options available this command accepts.
It forces me google for it to remember it and --omit dev still lists both prod and dev dependencies together so this might be the source of a different issue

Expected Behavior

Should list --prod among the list of options

Steps To Reproduce

  1. npm ls --help
  2. See --prod is missing

Environment

  • npm: 8.5.5
  • Node.js: v14.19.0
  • OS Name: ubuntu 20.04.1
@denik1981 denik1981 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 Apr 12, 2022
@denik1981 denik1981 changed the title [BUG] Can you please add --prod to the list of options available under npm ls --help? [BUG] Can you please add --prod to the list of options available under npm ls --help? Apr 12, 2022
@ljharb
Copy link
Contributor

ljharb commented Apr 12, 2022

hmm, i'd expect --only=prod to be the preferred alias, but that one's not listed either, only omit is.

@lukekarrys
Copy link
Contributor

lukekarrys commented Apr 12, 2022

only is deprecated, which I think is why its not listed for ls (or any other commands). https://docs.npmjs.com/cli/v8/using-npm/config#only

It forces me google for it to remember it and --omit dev still lists both prod and dev dependencies together so this might be the source of a different issue

This definitely seems like a bug. The docs explicitly call out: When set to prod or production, this is an alias for --omit=dev. Here's the output that from the cli itself, which directly contradicts that:

❯ npm ls --only prod | grep tap-snapshots/

❯ npm ls --omit dev | grep tap-snapshots/
│ ├── tap@16.0.1 deduped
│ ├── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ ├── tap@16.0.1 deduped
│ ├── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
│ └── tap@16.0.1 deduped
├── tap@16.0.1

@lukekarrys lukekarrys added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Apr 12, 2022
@denik1981
Copy link
Author

Yes, well I suppose the correct usage is with --omit dev as you say if it happens that --prod is deprecated.
Thanks for addressing this issue.

@lukekarrys lukekarrys changed the title [BUG] Can you please add --prod to the list of options available under npm ls --help? [BUG] npm ls --omit=dev does not omit dev dependencies Apr 13, 2022
@lukekarrys lukekarrys added the cmd:list related to `npm list` label Apr 13, 2022
lukekarrys added a commit that referenced this issue Apr 13, 2022
This makes `npm ls` use the same logic as other commands (eg `outdated`)
when parsing config items that filter the output based on package type.

Previously `--development` and `--production` has special semantics when
used with `npm ls` that were inconsistent with the rest of the CLI. To
achieve the same behavior as these deprecated flags use:

- in place of `--development` use `--omit peer --omit prod --omit optional`
- in place of `--production` use `--omit dev --omit peer`

Fixes #4739
lukekarrys added a commit that referenced this issue Apr 13, 2022
This makes `npm ls` use the same logic as other commands (eg `outdated`)
when parsing config items that filter the output based on package type.

Previously `--development` and `--production` has special semantics when
used with `npm ls` that were inconsistent with the rest of the CLI. To
achieve the same behavior as these deprecated flags use:

- in place of `--development` use `--omit peer --omit prod --omit optional`
- in place of `--production` use `--omit dev --omit peer`

Fixes #4739
fritzy pushed a commit that referenced this issue Apr 13, 2022
This makes `npm ls` use the same logic as other commands (eg `outdated`)
when parsing config items that filter the output based on package type.

Previously `--development` and `--production` has special semantics when
used with `npm ls` that were inconsistent with the rest of the CLI. To
achieve the same behavior as these deprecated flags use:

- in place of `--development` use `--omit peer --omit prod --omit optional`
- in place of `--production` use `--omit dev --omit peer`

Fixes #4739
@denik1981
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing cmd:list related to `npm list` Priority 1 high 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