Search code examples
yarnpkghoistingyarn-workspaces

How can I find the owner of a dependency that got hoisted to the root of a Yarn workspace?


In a project with several yarn workspaces if I do

yarn list --pattern some-package

I get a list with various versions of some-package, example:

yarn list v1.5.1
├─ project-a@0.0.0
│  └─ some-package@2.0.0
├─ project-z@0.0.0
│  └─ some-package@3.0.0
└─ some-package@1.0.0

In that example, is there a way to find what project added the dependency that got hoisted all the way to the root, some-package@1.0.0? There is no package.json file at the root, so it must have been hoisted from one of the projects.

Maybe hoisting debug logs?

I know I could grep the whole directory, but this is a very large code base.


Solution

  • You can get a breakdown with: yarn why some-package