Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'next/dist/server/next-server.js'. Turborepo + VercelCLI #48949

Open
1 task done
MrDockal opened this issue Apr 28, 2023 · 6 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template.

Comments

@MrDockal
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #76~20.04.1-Ubuntu SMP Mon Mar 20 15:54:19 UTC 2023
    Binaries:
      Node: 16.15.1
      npm: 8.19.1
      Yarn: 1.22.19
      pnpm: 7.29.1
    Relevant packages:
      next: 13.3.1
      eslint-config-next: 13.2.4
      react: 18.2.0
      react-dom: 18.2.0

----------------- 

Vercel CLI 28.20.0
28.20.0

Which area(s) of Next.js are affected? (leave empty if unsure)

Turbopack (--turbo)

Link to the code that reproduces this issue

https://github.com/MrDockal/nextjs-turbo-vercel-cli-issue

To Reproduce

  1. Clone the repo https://github.com/MrDockal/nextjs-turbo-vercel-cli-issue
  2. npx vercel build --token YOUR_VERCEL_TOKEN --cwd apps/web
  3. npx vercel deploy --prebuilt --token YOUR_VERCEL_TOKEN --yes --cwd apps/web
  4. Visit the /lambda page and you'll get 500. The root page / works

Describe the Bug

Hello,
When I deploy a lambda function (page with getServerSideProps implemented) to Vercel using Vercel CLI + Turborepo + NextJs. The lambda throws an error: Cannot find module 'next/dist/server/next-server.js' (it could similar to this issue #39432)
There isn't node_modules folder at all
image

I tried to deploy the same Nextjs app outside the Turborepo and it works. As you see there is node_modules folder with all required dependencies now
image

I don't know if this is an issue with Next, Turborepo or Vercel CLI itself.
Thank you

Expected Behavior

I expect endpoint /lambda to return 200 with HTML code

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@MrDockal MrDockal added the bug Issue was opened via the bug report template. label Apr 28, 2023
@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Apr 28, 2023
@padmaia padmaia removed the Turbopack Related to Turbopack with Next.js. label Apr 28, 2023
@padmaia
Copy link
Member

padmaia commented Apr 28, 2023

Removed the Turbopack label since it's related to production builds, which Turbopack does not support yet.

@jakeleventhal
Copy link
Contributor

Related issue: vercel/vercel#8794

@jakeleventhal
Copy link
Contributor

#39432 (reply in thread)
Check this out. Turbo unrelated

@MrDockal
Copy link
Author

MrDockal commented Jun 6, 2023

Right! thank you @jakeleventhal. This is definitely related to https://github.com/trappar/next-vercel-ssr-bug

@joseocabarcas
Copy link

I have the same issue with turborepo and pnpm when deploy with vercel cli prebuilt. The pages with getServerSideProps broken with Cannot find module 'next/dist/server/[next-server](https://linear.app/vercel/issue/NEXT-server).js'
Any solutions or workaround?

@jakeleventhal
Copy link
Contributor

Should close this as a duplicate of vercel/vercel#8794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

5 participants
@padmaia @MrDockal @joseocabarcas @jakeleventhal and others