Why and when does yarn decide not to hoist a package in a workspace?

Viewed 886

I'm working on a large project using yarn workspaces. I know that yarn workspaces essentially does two things

  • It automates the symlinking process we had to do manually years ago when we want to share private packages
  • It hoists all similar packages at the top in node_modules in order to be more efficient.

However, I have noticed that my packages still contain code in their own node_modules and I'm not sure why. When I make a sample monorepo app and say I install lodash in one, it goes straight to the root node_modules.

Why and when does yarn decide to install a package inside a package's node_modules ?

1 Answers

I found the answer on yarn's Discords. yarn will always hoist unless it would conflict with another version.

Related