How to use “nohoist” in Yarn workspaces?

Levente Balogh
1 min readAug 27, 2020

--

Sometimes you are in a state where you don’t want your underlying package dependencies to be hoisted to the root level.

Unfortunately from the Yarn docs it’s not super straightforward how to configure this setting in case you have multiple packages under a subdirectory:

/packages/
/pkgA/
/pkgB/

Let’s say our goal is to stop hoisting any dependencies living under pkgA to the root level.

Working patterns for this scenario:

- "**"
- "pkgA/**"
- "**/pkgA/**"

NOT working patterns for this sceanrio:

- "pkgA"
- "**/plugins/pkgA"
- "**/plugins/pkgA/**"

A working package.json file snippet:

More info: https://classic.yarnpkg.com/blog/2018/02/15/nohoist/

--

--

Levente Balogh

I think one of the most important thing in our life is curiosity. Stay curious, understand truly how things work and become a master craftsman. This is my goal.