cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] Can not get `npm ls` to show origin of an optional dependency

Open inwenis opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

npm ls node-gyp-buid
[email protected] C:\git\test-npm
`-- (empty)

Expected Behavior

npm ls node-gyp-buid
[email protected] C:\git\test-npm
[email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        └── [email protected]

Steps To Reproduce

npm init -y
npm install kafka-lz4-lite@latest
npm ls node-gyp-buid
npm ls --all node-gyp-buid
npm ls --include=optional node-gyp-buid

Environment

  • npm: 10.7.0
  • Node.js: v22.0.0
  • OS Name: win
  • System Model Name:
  • npm config:
; "user" config from ...

msbuild_path = "c:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"
msvs_version = "2017"

; node bin location = C:\programki\nodejs\node.exe
; node version = v22.0.0
; npm local prefix = C:\git\test-npm
; npm version = 10.7.0
; cwd = C:\git\test-npm
; HOME = ...
; Run `npm config ls -l` to show all defaults.

inwenis avatar May 15 '24 11:05 inwenis

Is the dependency actually installed? npm ls will only show the packages that are actually installed.

wraithgar avatar May 15 '24 14:05 wraithgar

thank you for the reply @wraithgar The pacakge I'm looking for is not present in node_modules. Is there a way to analyse the deprendency tree including optional deps?

inwenis avatar May 18 '24 12:05 inwenis

@inwenis I think you meant npm ls node-gyp-build and not npm ls node-gyp-buid

This is my output from the steps you mentioned on 10.8.1, looks correct for me.

~/workarea/rep/test $ npm ls --all node-gyp-build             
[email protected] /Users/milaninfy/workarea/rep/test
└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └── [email protected]

~/workarea/rep/test $ npm ls node-gyp-build 
[email protected] /Users/milaninfy/workarea/rep/test
└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └── [email protected]

milaninfy avatar Jun 27 '24 15:06 milaninfy

@milaninfy you're right a made a typo however you're getting the dependency tree cuz you're on linux, my issue is that I ran it on windows

inwenis avatar Jul 01 '24 13:07 inwenis