Monorepo module resolution issue
Hi everyone,
I'm facing an issue with a Next.js application in a pnpm monorepo workspace and would appreciate any help. It's probably just some config issue from my side, but I've been pulling my hair out over this the last few days!
I have a monorepo using pnpm with two packages:
I can successfully import and use code from the api package in the next package as long as the api package does not use TypeScript path aliases.
When I enable path aliases in the api package's tsconfig.json, the Next.js build and dev server process fails. TypeScript and ESLint in the next package recognize the imports and types without issues, but the Next.js build throws module resolution errors related to the path aliases used in the api package.
I want to be able to:
- Use path aliases in every package for cleaner imports.
- Import the api package into the next package without having to build the api package separately.
- Let Next.js handle the build process, including resolving the path aliases used in the api package.
I've created a minimal repo to reproduce the issue. Any help would be greatly appreciated!
https://github.com/kyrregjerstad/next-monorepo
GitHub
GitHub - kyrregjerstad/next-monorepo
Contribute to kyrregjerstad/next-monorepo development by creating an account on GitHub.
1 Reply
gentle bump, would love some input on this, even just if it's possible to achieve what i'm looking for