Search code examples
pnpm

Access peer dependency types in pnpm without making package a direct dependency


I use lib A, which has a peer dependency upon lib B. In my app code, I'd like to pull types from lib B, but pnpm's setup of the node_modules/ directory (at least out of the box) breaks this, the module in whole is unavailable.

How do I configure pnpm to let me access peer dependency types? It makes no sense to add B as a direct dependency as I don't use it as a direct dependency in any capacity at runtime.


Solution

  • Turns out it's the poorly named shamefully-hoist option (with little in the way to describe how it differs from hoist, which is enabled by default) in the incorrectly named .npmrc.

    Docs: https://pnpm.io/npmrc#shamefully-hoist