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 list -g missing resolved field for Github-based dependencies #8173

Open
2 tasks done
bhuynhdev opened this issue Mar 20, 2025 · 0 comments
Open
2 tasks done
Labels
Bug thing that needs fixing Needs Triage needs review for next steps

Comments

@bhuynhdev
Copy link

bhuynhdev commented Mar 20, 2025

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

If I install a package from Github URL globally, then use npm list -g --json <package_name>, npm does NOT include the field resolved and thus I lose out on important information, including which commit hash was this package installed from. (more details in reproduction steps below)

This only happens on a global level. If I installed the package to a local node project (i.e. without -g flag), then npm list correctly shows the commit hash information.

Expected Behavior

npm list --global should behave like npm list and shows resolved field and commit hash for package installed from Github URL

I dug through some npm versions and discovered that up until v7.5.5, npm list --global still works as expected and shows the commit hash for global packages. However, since v7.5.6 until now, this behavior no longer exists.

Steps To Reproduce

  1. mkdir test-node-app && cd test-node-app && npm init
  2. npm install [email protected]:bhuynhdev/test-pkg-public.git
  3. npm list --json test-pkg-public
  4. Clearly see the commit hash of this installed package
{
  "version": "1.0.0",
  "name": "test-node-app",
  "dependencies": {
    "test-pkg-public": {
      "version": "1.0.0",
      "resolved": "[email protected]/bhuynhdev/test-pkg-public.git#4ef9031cbfa6185c87084a30aa924005b63a5d8a",
      "overridden": false
    }
  }
}
  1. Now install this package globally npm install --global [email protected]:bhuynhdev/test-pkg-public.git
  2. npm list --global --json test-pkg-public
  3. ⚠️ See that package listing no longer has commit hash information
{
  "name": "lib",
  "dependencies": {
    "test-pkg-public": {
      "version": "1.0.0",
      "overridden": false
    }
  }
}

Environment

  • npm: 10.9.2
  • Node.js: 22.14.0
  • OS Name: Macbook M2 Pro - Sequoia 15.3.2
  • npm config:
; node bin location = /Users/user/.asdf/installs/nodejs/22.14.0/bin/node
; node version = v22.14.0
; npm local prefix = /Users/user/code/git/test-node-app
; npm version = 10.9.2
; cwd = /Users/user/code/git/test-node-app
; HOME = /Users/user
; Run `npm config ls -l` to show all defaults.
@bhuynhdev bhuynhdev added Bug thing that needs fixing Needs Triage needs review for next steps labels Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

1 participant