1

Whilst addressing GitHub dependabot updates, I've been looking through the dependencies list created after running npm ls -a.

I (think I) understand the nesting involved: a pipe indicates that packages below are part of the dependencies list, and so on.

see image created from running npm ls -a > file.txt

What I don't understand is the difference between +-- and `--.

After looking at it for the best part of an hour (embarassingly) my best guess is that `-- indicates the last package in a given nesting, whilst +-- is an indication there are more packages.

It would be great if anybody could help clarify and enlighten me on what's getting output here.

mjwils
  • 456
  • 4
  • 12

1 Answers1

1

Yep, it just means "the last one at this level". Depending on your locale, npm draws a nice little Unicode box drawing "end hook" thing, or the approximation you were seeing:

/tmp/example > LC_ALL=en_US.UTF-8 npm ls -a
example@ /tmp/example
└─┬ string-width@5.1.2
  ├── eastasianwidth@0.2.0
  ├── emoji-regex@9.2.2
  └─┬ strip-ansi@7.0.1
    └── ansi-regex@6.0.1

/tmp/example > LC_ALL=C npm ls -a
example@ /tmp/example
`-- string-width@5.1.2
  +-- eastasianwidth@0.2.0
  +-- emoji-regex@9.2.2
  `-- strip-ansi@7.0.1
    `-- ansi-regex@6.0.1

If you don't want to change your locale, but do want npm ls to use the better-looking glyphs, you can pass --unicode.

Wander Nauta
  • 18,832
  • 1
  • 45
  • 62
  • That --unicode flag is splendid and is significantly helpful. Many thanks for your assistance. – mjwils Jun 30 '22 at 11:16