npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.17k stars 2.97k forks source link

[BUG] Aliased packages ignored by `npm list` #3833

Open jacob418 opened 2 years ago

jacob418 commented 2 years ago

Is there an existing issue for this?

Current Behavior

npm list [pkg] list only packages that have name = pkg but not packages with alias = pkg

Example:

$ npm list uuid         
1Independent@0.8.3 /path/to/my/project
├─┬ @vue/cli-plugin-babel@4.5.13
│ └─┬ @vue/cli-shared-utils@4.5.13
│   └─┬ request@2.88.2
│     └── uuid@3.4.0
├─┬ @vue/cli-plugin-e2e-cypress@4.5.13
│ └─┬ cypress@3.8.3
│   └─┬ request@2.88.0
│     └── uuid@3.4.0
├─┬ @vue/cli-service@4.5.13
│ ├─┬ copy-webpack-plugin@5.1.2
│ │ └─┬ webpack-log@2.0.0
│ │   └── uuid@3.4.0
│ └─┬ webpack-dev-server@3.11.2
│   └─┬ sockjs@0.3.21
│     └── uuid@3.4.0
└─┬ cordova@10.0.0
  └─┬ insight@0.10.3
    └── uuid@3.4.0

Expected Behavior

I would expect the command to also list installations of the package with name = pkg where alias != pkg, indicating, it has been aliased on the entry of the package tree.

Example:

$ npm list uuid         
1Independent@0.8.3 /path/to/my/project
├─┬ @vue/cli-plugin-babel@4.5.13
│ └─┬ @vue/cli-shared-utils@4.5.13
│   └─┬ request@2.88.2
│     └── uuid@3.4.0
├─┬ @vue/cli-plugin-e2e-cypress@4.5.13
│ └─┬ cypress@3.8.3
│   └─┬ request@2.88.0
│     └── uuid@3.4.0
├─┬ @vue/cli-service@4.5.13
│ ├─┬ copy-webpack-plugin@5.1.2
│ │ └─┬ webpack-log@2.0.0
│ │   └── uuid@3.4.0
│ └─┬ webpack-dev-server@3.11.2
│   └─┬ sockjs@0.3.21
│     └── uuid@3.4.0
├─┬ cordova@10.0.0
│ └─┬ insight@0.10.3
│   └── uuid@3.4.0
└── uuid@8.3.2 as uuid8

Notice the last line (new):

└── uuid@8.3.2 as uuid8

*the part as uuid8 indicates the alias and is only a suggestion, it might look completely different.

Steps To Reproduce

  1. Create VUE-CLI project
  2. Install the uuid package with alias (npm install uuid8@npm:uuid@8)
  3. Run npm list uuid
  4. => The version 8 installation of uuid is not showing up

Environment

cjz9032 commented 1 year ago

Me too, and what's the plan to this issue?