next.js: [turborepo] [turbopack] Running a NextJs app by using the --turbo flag in the TurboRepo monorepo, causes Error: Next.js package not found
Link to the code that reproduces this issue
https://codesandbox.io/s/focused-newton-8l2xcm
To Reproduce
- Fresh install of TurboRepo monorepo
- Run the web NextJs app by using the
--turboflag - Open the
http://localhost:3000on your browser Internal Server Error- Check out the terminal
Current vs. Expected behavior
Dev build and run the project must work but right after npm run dev and opening the browser it falls into the Server error:
Full LOG
Debug info:
- Execution of get_next_package failed
- Next.js package not found
at withErrorCause (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:391:19)
at async EndpointImpl.writeToDisk (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:581:20)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-utils/setup-dev.js:922:79)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-server.js:87:24)
at async DevServer.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:510:9)
at async Object.ensure (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:163:17)
at async DevRouteMatcherManager.matchAll (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/future/route-matcher-managers/dev-route-matcher-manager.js:94:13)
at async DevRouteMatcherManager.match (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js:159:26)
at async DevServer.handleCatchallRenderRequest (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/next-server.js:567:27)
at async DevServer.handleRequestImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:728:17) {
[cause]: [Error: Next.js package not found
Debug info:
- Execution of get_next_package failed
- Next.js package not found] {
code: 'GenericFailure'
}
}
Error: expected next/dist/client/next-dev-turbopack.js to resolve to a module
Debug info:
- Execution of PageEndpoint::client_chunks failed
- expected next/dist/client/next-dev-turbopack.js to resolve to a module
at withErrorCause (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:391:19)
at async EndpointImpl.writeToDisk (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:581:20)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-utils/setup-dev.js:790:77)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-server.js:87:24)
at async DevServer.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:510:9)
at async DevServer.findPageComponents (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:526:17)
at async DevServer.renderErrorToResponseImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:1804:26)
at async pipe.req.req (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:1732:30)
at async DevServer.pipeImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:826:25)
at async DevServer.handleCatchallRenderRequest (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/next-server.js:638:17)
at async DevServer.handleRequestImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:728:17) {
[cause]: [Error: expected next/dist/client/next-dev-turbopack.js to resolve to a module
Debug info:
- Execution of PageEndpoint::client_chunks failed
- expected next/dist/client/next-dev-turbopack.js to resolve to a module] {
code: 'GenericFailure'
}
}
Error: Next.js package not found
Debug info:
- Execution of get_next_package failed
- Next.js package not found
at withErrorCause (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:391:19)
at async EndpointImpl.writeToDisk (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:581:20)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-utils/setup-dev.js:922:79)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-server.js:87:24)
at async DevServer.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:510:9)
at async Object.ensure (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:163:17)
at async DevRouteMatcherManager.matchAll (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/future/route-matcher-managers/dev-route-matcher-manager.js:94:13)
at async DevRouteMatcherManager.match (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js:159:26)
at async DevServer.handleCatchallRenderRequest (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/next-server.js:567:27)
at async DevServer.handleRequestImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:728:17) {
[cause]: [Error: Next.js package not found
Debug info:
- Execution of get_next_package failed
- Next.js package not found] {
code: 'GenericFailure'
}
}
Error: expected next/dist/client/next-dev-turbopack.js to resolve to a module
Debug info:
- Execution of PageEndpoint::client_chunks failed
- expected next/dist/client/next-dev-turbopack.js to resolve to a module
at withErrorCause (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:391:19)
at async EndpointImpl.writeToDisk (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:581:20)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-utils/setup-dev.js:790:77)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-server.js:87:24)
at async DevServer.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:510:9)
at async DevServer.findPageComponents (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:526:17)
at async DevServer.renderErrorToResponseImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:1804:26)
at async pipe.req.req (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:1732:30)
at async DevServer.pipeImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:826:25) {
[cause]: [Error: expected next/dist/client/next-dev-turbopack.js to resolve to a module
Debug info:
- Execution of PageEndpoint::client_chunks failed
- expected next/dist/client/next-dev-turbopack.js to resolve to a module] {
code: 'GenericFailure'
}
}
Error: expected next/dist/client/next-dev-turbopack.js to resolve to a module
Debug info:
- Execution of PageEndpoint::client_chunks failed
- expected next/dist/client/next-dev-turbopack.js to resolve to a module
at withErrorCause (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:391:19)
at async EndpointImpl.writeToDisk (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:581:20)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-utils/setup-dev.js:790:77)
at async Object.getFallbackErrorComponents (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-server.js:99:17)
at async DevServer.getFallbackErrorComponents (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:553:9)
at async DevServer.renderErrorToResponseImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:1875:40)
at async pipe.req.req (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:1732:30)
at async DevServer.pipeImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:826:25) {
[cause]: [Error: expected next/dist/client/next-dev-turbopack.js to resolve to a module
Debug info:
- Execution of PageEndpoint::client_chunks failed
- expected next/dist/client/next-dev-turbopack.js to resolve to a module] {
code: 'GenericFailure'
}
}
⨯ Error: Next.js package not found
Debug info:
- Execution of get_next_package failed
- Next.js package not found
at withErrorCause (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:391:19)
at async EndpointImpl.writeToDisk (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/build/swc/index.js:581:20)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-utils/setup-dev.js:946:79)
at async Object.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/lib/router-server.js:87:24)
at async DevServer.ensurePage (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:510:9)
at async Object.ensure (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/dev/next-dev-server.js:163:17)
at async DevRouteMatcherManager.matchAll (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/future/route-matcher-managers/dev-route-matcher-manager.js:94:13)
at async DevRouteMatcherManager.match (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/future/route-matcher-managers/default-route-matcher-manager.js:159:26)
at async DevServer.handleCatchallRenderRequest (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/next-server.js:567:27)
at async DevServer.handleRequestImpl (/Users/MacBookPro_ProjectsDirectory/test-next-turborepo/node_modules/next/dist/server/base-server.js:728:17) {
[cause]: [Error: Next.js package not found
Debug info:
- Execution of get_next_package failed
- Next.js package not found] {
code: 'GenericFailure'
}
}
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.5.0
Binaries:
Node: 18.14.1
npm: 9.3.1
Yarn: 1.22.19
Relevant Packages:
next: 13.4.19
eslint-config-next: 13.4.20
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Which area(s) are affected? (Select all that apply)
Turbopack (–turbo)
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 11
- Comments: 15 (5 by maintainers)
Same error with pnpm monorepo as well.
Still relevant in Next.js 14.0.1.
It doesn’t work in an Nx monorepo with yarn.
@balazsorban44
Please do the following steps exactly one by one:
npx create-turbo@latestamer-reproducebun(with npm and yarn it works properly)webapplication in theappsfolderwebproject open thepackage.jsonfile and edit thedevscriptwebapp of theamer-reproducefolder and type the following command:Internal Server Erroron the browserI still get this error with yarn on next 14.1
Hi, I tried reproducing it, but couldn’t. I see you are on
13.4.19which is not the latest version. Can you try to update tonext@canaryornext@latestand report back?