npm / npm/cli

[BUG] Aliased packages ignored by `npm list`

Open
#3,833 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug config:aliases Priority 2
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
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
  • OS: Linux 5.4.0-81 (Regolit/Ubuntu)
  • Node: 14.17.6
  • npm: 7.24.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with npm install uuid8@npm:uuid@8 and npm list uuid in a Vue CLI project. Trace the npm list command's package-tree filtering for the package name versus its alias. Done means the output includes the aliased uuid@8.3.2 installation, with an indication of its alias, while retaining the existing matches.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.