TypeScript Monorepos with Yarn

Originally published at: https://semaphoreci.com/blog/typescript-monorepos-with-yarn

A tutorial showing how to configure TypeScript to work in a monorepo and building everything with CI/CD.

Hi, thanks so much for the tutorial, I followed it up to yarn tsc --build --force and the build fails right there with error TS2307: Cannot find module 'shared' or its corresponding type declarations. I can’t spot what I did not follow from your example. Anything out you or I might haver left out?

Hi Binh,

I reproduced the problem and tracked it down to the latest yarn version. It seems that the new version (3.1.0) introduced some changes in how it handles PnP dependencies:

"ESM support for PnP uses the experimental loader API and is therefore experimental"

I was able to fix the error by switching to an older version of Yarn:

yarn set version 3.0.1

You may need to clear the whole cache and the pnp file after doing the switch. Let me know if it helps!