Yarn: Yarn list doesn't match NPM

Created on 6 Mar 2017  Β·  8Comments  Β·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Doesn't correctly show where a dep is coming from.

Joes-MacBook-Pro:react-scripts joe$ yarn list loader-utils
yarn list v0.21.3
β”œβ”€ [email protected]
β”‚  └─ [email protected]
β”œβ”€ [email protected]
β”‚  └─ [email protected]
└─ [email protected]

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?

Joes-MacBook-Pro:react-scripts joe$ npm ls loader-utils
[email protected] /Users/joe/Documents/Development/OSS/create-react-app/packages/react-scripts
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected] 
β”œβ”€β”¬ [email protected]
β”‚ └── [email protected] 
└─┬ [email protected]
  └── [email protected] 

Please mention your node.js, yarn and operating system version.

Joes-MacBook-Pro:react-scripts joe$ node -v
v6.10.0
Joes-MacBook-Pro:react-scripts joe$ npm -v
3.10.10
Joes-MacBook-Pro:react-scripts joe$ yarn --version
0.21.3
cat-compatibility help wanted needs-discussion triaged

Most helpful comment

Even when you install with Yarn only, npm list shows a tree whereas yarn list shows a flat list (which is quite useless).

Example:
https://github.com/alexilyaev/react-es6-starter

$ yarn list wrappy
yarn list v1.2.1
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
✨  Done in 0.63s.
$ npm list wrappy
[email protected] /Users/alex/www/Node/Personal/react-es6-starter
β”œβ”€β”¬ [email protected]
β”‚ └─┬ [email protected]
β”‚   β”œβ”€β”¬ [email protected]
β”‚   β”‚ └── [email protected]
β”‚   └─┬ [email protected]
β”‚     └── [email protected]  deduped
└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        β”œβ”€β”¬ [email protected]
        β”‚ └─┬ [email protected]
        β”‚   └─┬ [email protected]
        β”‚     └── [email protected]  deduped
        └─┬ [email protected]
          └─┬ [email protected]
            └── [email protected]

P.S.

What's up with the warning of using a filter?
Do I have to use yarn list --pattern wrappy now?

Why make life harder?!

All 8 comments

Also, it doesn't seem to have a way to list the production-only dependencies of the project. No matter if prior to running yarn list you've only run yarn install -production or even more ideally it would work to run yarn list --production regardless of what was installed, like works with npm.

I stumbled upon these differences as well.
I would also like yarn to copy the npm ls format.
It is prettier, more effective and more useful (IMHO;)
yarn list --depth=0 should just list the production (top level) packages. like npm ls does.
maybe have a yarn list --flat do the current bahaviour.

but i like the coloring, to be fair :-)

Still an issue:

$ npm list postcss-reporter
[email protected] /path/to/project
└─┬ [email protected]
  └── [email protected]
$ yarn list postcss-reporter
yarn list v1.0.1
└─ [email protected]
✨  Done in 0.71s.

Tested on my repo:
https://github.com/alexilyaev/react-es6-starter

I can repro this by creating a set of bogus nested packages. I see that the output depends on how you install it.

If you install the package through npm then npm will show you the tree while yarn does not.

When you install it through yarn then both engines show the same flat tree (and then npm displays warnings about packages being extraneous).

I can try to fix this but something tells me this is working as intended as a side effect of how yarn organizes packages.

Please discuss the best way to resolve this ticket.

I put the example up here:
https://github.com/qfox/yarn/tree/list-yarn-vs-npm/__tests__/fixtures/list/match-npm

And actually, yarn list level5 doesn't even work unless you have installed the package with yarn. I think it reads the information from the yarn.lock file either way. It will bail the list command if that file doesn't exist.

Even when you install with Yarn only, npm list shows a tree whereas yarn list shows a flat list (which is quite useless).

Example:
https://github.com/alexilyaev/react-es6-starter

$ yarn list wrappy
yarn list v1.2.1
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ [email protected]
✨  Done in 0.63s.
$ npm list wrappy
[email protected] /Users/alex/www/Node/Personal/react-es6-starter
β”œβ”€β”¬ [email protected]
β”‚ └─┬ [email protected]
β”‚   β”œβ”€β”¬ [email protected]
β”‚   β”‚ └── [email protected]
β”‚   └─┬ [email protected]
β”‚     └── [email protected]  deduped
└─┬ [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        β”œβ”€β”¬ [email protected]
        β”‚ └─┬ [email protected]
        β”‚   └─┬ [email protected]
        β”‚     └── [email protected]  deduped
        └─┬ [email protected]
          └─┬ [email protected]
            └── [email protected]

P.S.

What's up with the warning of using a filter?
Do I have to use yarn list --pattern wrappy now?

Why make life harder?!

Any workaround for finding that information besides manually tracking down dependencies :(

edit: I guess if you're desperate like me and have too many dependencies to do manually you can blow away yarn.lock and generate the the package-lock.json. I also had to delete my .npmrc file which was supressing the generation of the package-lock.json.

Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2020-10-15 Π² 18 58 50

I could't find the --pattern option. Why you show that warning? --cache-folder, --focus, --no-progress other are "very important" options, but the most popular without any manuals is just yarn list package.

Was this page helpful?
0 / 5 - 0 ratings