2

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.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Yoni hodeffi
  • 103
  • 2
  • 8
  • perhaps your build is not running in topological order, are you sure that each package have the dependencies in each `package.json` files? For example, I assume next/app has to be built before MyApp since it seems to be a dependency – ghiscoding Nov 30 '22 at 14:59
  • @ghiscoding it doesn't really matter, I was able to replicate this when creating a fresh create-next-app with yarn plugnplay (latest), it's a problem with next I think, I already submitted an issue. for now, until it is supported I moved to nodeLinker: pnpm – Yoni hodeffi Dec 01 '22 at 15:12
  • ah ok I never tried Yarn PNP, since I also prefer pnpm with the [`workspace:`](https://pnpm.io/workspaces#workspace-protocol-workspace) protocol which I also use in [Lerna-Lite](https://github.com/ghiscoding/lerna-lite) (a lighter alternative to Lerna) itself, both managers are supported by Lerna/Lerna-Lite. Maybe a side comment, make sure to not use `lerna boostrap` with recent package managers, that command will be removed in Lerna and was never added to Lerna-Lite since it's no longer needed and can conflicts with the package manager – ghiscoding Dec 01 '22 at 15:21

1 Answers1

1

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

JoyGuilherme
  • 106
  • 2