I have a monorepo using Yarn workspaces. I have one package based on create-react-app which should import from a common module (sibling package in the repo).
This common package doesn't contain any React components. Just business logic. Its source is transpiled from Typescript. The common package works fine with my backend code in other packages.
Out of the box this doesn't work with CRA and gives me an error:
./src/App.tsx Module not found: Can't resolve '@gemini/common'
What do I need to do to configure CRA to find the module?
I found this open issue on CRA monorepo support, but I'm unsure how it relates and there's a lot of information in there.
Lets assume your structure is similar to
|- monorepo
|- package.json
|- packages
|- cra
| |- package.json
|
|- common
|- package.json
// monorepo/packages.json
{
"workspaces": {
"packages": [
"packages/*"
]
},
}
// monorepo/packages/gemini/package.json
{
"name": "@gemini/common"
}
// monorepo/packages/cra/package.json
{
"dependencies": {
"@gemini/common": "*"
}
}
yarn
to link gemini in craIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With