Monorepo with NPM Workspaces and Typescript

I recently needed to set up a project with a monorepo and was searching about for a good guide or example. Nothing I found was quite right. This repo had a rather extensive example but brought in lerna, which I wanted to avoid. This one was a bit simpler but was using yarn in the examples.

I created ts-npm-monorepo as a bare-bones example for how to set up a monorepo with Typescript using only NPM Workspaces.

This is working well: I only have one copy of node_modules at the root and all the packages share it. The packages are set up with Typescript project references, so everything builds in the proper order and changes are immediately reflected. I can also add any shared external dependencies in the root package.json and they’ll be available in any package in the repo.

(Edit) After reading up a bit more on Yarn it’s pretty great and I’ve switched to using Yarn workspaces.

Leave a Reply

Your email address will not be published. Required fields are marked *