Description
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
- mkdir
test-node-app
&& cdtest-node-app
&&npm init
npm install [email protected]:bhuynhdev/test-pkg-public.git
npm list --json test-pkg-public
- 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
}
}
}
- Now install this package globally
npm install --global [email protected]:bhuynhdev/test-pkg-public.git
npm list --global --json test-pkg-public
⚠️ 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.