Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[DOCS] npm ls --depth default is 0 not 1 #7979

Open
2 tasks done
MikeMcC399 opened this issue Dec 12, 2024 · 1 comment
Open
2 tasks done

[DOCS] npm ls --depth default is 0 not 1 #7979

MikeMcC399 opened this issue Dec 12, 2024 · 1 comment
Labels
Documentation documentation related issue Needs Triage needs review for next steps

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Dec 12, 2024

Is there an existing issue for this?

  • I have searched the existing issues

This is a CLI Docs Problem, not another kind of Docs Problem.

  • This is a CLI Docs Problem.

Description of Problem

When using npm ls, with no depth option specified, the output is the same as when npm ls --depth=0 is specified. The documentation npm ls --depth however states that the default depth is 1, not 0:

depth

  • Default: Infinity if --all is set, otherwise 1
  • Type: null or Number

The depth to go when recursing packages for npm ls.

If not set, npm ls will show only the immediate dependencies of the root project. If --all is set, then npm will show all dependencies by default.

Steps to reproduce

Ubuntu 24.04.1 LTS, Node.js v22.12.0 LTS
npm v10.9.2

git clone https://github.com/npm/cli
cd cli
git checkout v10.9.2
npm ci
npm install npm@latest -g
npm -v
npm ls | wc -l
npm ls --depth=0 | wc -l
npm ls --depth=1 | wc -l
npm ls --depth=2 | wc -l

Results

Line count resulting from running npm ls --depth=n against https://github.com/npm/cli tag v10.9.2

npm ls --depth=n Line count
unspecified 276
0 276
1 592
2 1086

Potential Solution

Change the documented default depth for npm ls --depth from 1 to 0

Affected URL

https://docs.npmjs.com/cli/v10/commands/npm-ls#depth

@MikeMcC399 MikeMcC399 added Documentation documentation related issue Needs Triage needs review for next steps labels Dec 12, 2024
@MikeMcC399
Copy link
Contributor Author

Confirmed that this issue also applies to npm@11.0.0

Documentation link https://docs.npmjs.com/cli/v11/commands/npm-ls#depth

Results of running npm ls --depth=n using npm@latest (11.0.0) are the same.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Documentation documentation related issue Needs Triage needs review for next steps
Projects
None yet
Development

No branches or pull requests

1 participant