nx: Error on Vercel Nextjs deploy

Current Behavior

Deploy Nextjs monorepo gets an error

Steps to Reproduce

  1. Create nx workspace with Nextjs preset.
  2. Go to Vercel account.
  3. Import repository.
  4. Modify default commands on Vercel:

Build command: nx build <app> Directory: dist/apps/<app>

Failure Logs


Error: A "routes-manifest.json" couldn't be found. This is normally caused by a misconfiguration in your project.
Please check the following, and reach out to support if you cannot resolve the problem:
1. If present, be sure your `build` script in "package.json" calls `next build`.  2. Navigate to your project's settings in the Vercel dashboard, and verify that the "Build Command" is not overridden, or that it calls `next build`.  3. Navigate to your project's settings in the Vercel dashboard, and verify that the "Output Directory" is not overridden. Note that `next export` does **not** require you change this setting, even if you customize the `next export` output directory. Learn More: https://err.sh/vercel/vercel/now-next-routes-manifest


Environment

@nrwl/cli: 10.3.2 @nrwl/next: 10.3.2 next: 10.0.1 typescript: 4.0.3

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 30 (4 by maintainers)

Most upvoted comments

You can’t? An alternative to modify workspace.json is create a build command on package.json: "build:app": "nx build app --outputPath . and override build command on Vercel. This works for me. Leo Lamprecht, dev on Vercel, says that they are working with optimizarions for NX workspaces. But, for now, he says that this is the solution.

Vercel Support Twitter send me this: https://twitter.com/vercel_support/status/1325770048934465537?s=20

Hello Cristian,

We don't support NX-powered apps at the moment. Our team is working on making this feature available for you shortly, and we should get back to you once we support NX.

Hello I’m trying to deploy a new Nx project into Vercel, but I have the same issue. The development branch deployment works fine, but when I click on “Promote to production”, I have the following error:

Error! The file "/vercel/path0/dist/apps/web/.next/routes-manifest.json" couldn't be found. This is normally caused by a misconfiguration in your project.

It seems to be related to build cache. There’s another thread about this specific behavior : https://github.com/nrwl/nx/issues/8294

Merged @JamesHenry 's PR with the docs changes (https://github.com/nrwl/nx/pull/4483).

We will deploy it to nx.dev later this week.

I’m going to close this issue, folks.

Thank you, everyone!

Sorry for the confusion @cenguidanos I didn’t mean for you to close this one - this one is regarding deployments on Vercel, that’s important and until my docs PR is merged it doesn’t have an “official” solution.

I was merely saying that issues with local development and Next.js are out of scope for this specific issue

Hi folks 👋

We have worked together with Vercel to improve the configuration required to deploy Next.js apps on Vercel from Nx workspaces. Additional/custom scripts are no longer required.

Please see the updated guidance here https://github.com/nrwl/nx/pull/4483, it is available for you to implement immediately.

Once the PR is merged, the updated guidance will also be available on https://nx.dev/latest/react/guides/nextjs

Thanks!

In my view this is the most optimal Nx + Next.js + Vercel setup that is available today: https://github.com/nrwl/nx/issues/3051#issuecomment-737482131

Hi there @cenguidanos ! Sorry, you’re right, your request makes sense! I’ll take a look on this next week! In the meantime, I would suggest you can try some different output directories or configurations on Vercel?

Hi there @cenguidanos !

Thanks for filing an issue!

You can solve this issue by choosing “Framework preset: Other”

Screenshot 2020-11-06 at 1 22 06 PM

Take a look at this issue and this comment here.

Let me know if you need any more assistance, or I can close this issue!