Create a Shared Library in a pnpm Workspace

Share this video with your friends

Send Tweet

You can create private libraries in your monorepo that you can share between your other packages and applications.

To do this all you need to do is create a new folder containing a package.json in your packages directory. You can then use pnpm filter commands to add external libraries to your package without ever having to cd into it!

Then just make sure to create an entry point and set the main field in your package.json to where your code will compile when built.

Javier Fuentes Mora
~ a year ago

For me this was not working I had to install @types/node and @types/react

Juri Strumpflohnerinstructor
~ a year ago

🤔 interesting. What exactly didn't work?