Next.js with Yarn pnp in a mono repo keep failing when trying to build

1.3k Views Asked by At

I am running Next.js 13.0.5 with Yarn 3.2.1 and Lerna 5.6.1.

It seems like the main problem here is the build tool, because when I run the Next.js server itself (yarn dev) everything works perfectly.

What error am I getting?

Type error: Cannot find module 'next/app' or its corresponding type declarations.

which happens here right at the start of the program

import type { AppProps } from 'next/app'
                   ^
function MyApp({ Component, pageProps }: AppProps) {
   return <Component {...pageProps} />
}

After looking around I tried some experimental features like swcFileReading : false but it doesn't seem to have any effect.

1

There are 1 best solutions below

0
On

try:

yarn dlx @yarnpkg/sdks vscode

Then you don't need to fallback to nodeLinker: node-modules as other StackOverflow suggestions to this problem. It resolved for me!

for more info check the yarn/ts issue: https://github.com/yarnpkg/berry/issues/4872#issuecomment-1284318301