Skip to content

[BUG] npm list -g missing resolved field for Github-based dependencies #8173

Open
@bhuynhdev

Description

@bhuynhdev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions