NextJs vercel deployment error "routes-manifest.json" couldn't be found
Asked Answered
S

9

9

My nextjs app was working properly I added some files to update my code now it is not deploying my app on vercel. gives this error

enter image description here

I tried googling the error but my case in unique.

This is the git repo https://github.com/usman-174/google-calendar-frontend

These are my script tags from package.json

 "scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"export": "next export",
"lint": "next lint",
"lint-fix": "next lint --fix"
},

next.config.js

module.exports = {
distDir: 'build',
}
Szymanski answered 18/1, 2022 at 16:5 Comment(0)
D
9

Assuming that you're using turbo with pnpm

1. Verify your package names in package.json files

Imagine you have a structure like this:

root/
├─ apps/
│  ├─ web/
├─ packages/
│  ├─ tsconfig/

And this is your pnpm-workspace.yaml file:

packages:
  - "apps/*"
  - "packages/*"

Then you have to make sure that name field in package.json file in your web project is representing web as well, like so:

{
    "name": "web",
    "scripts": {
        "dev": "next dev",
        "build": "next build",
    },
    // ...
}

2. Double-check your root package.json and turbo.json files

A minimal root package.json in a turborepo project:

{
    "scripts": {
        "build": "turbo run build",
        "dev": "turbo run dev",
    },
    "devDependencies": {
        "turbo": "^1.8.3"
    },
    "packageManager": "[email protected]"
}

And the turbo.json file at the root:

{
    "$schema": "https://turbo.build/schema.json",
    "pipeline": {
        "build": {
            "dependsOn": ["^build"],
            "outputs": [".next/**", "!.next/cache/**"]
        },
        "dev": {
            "cache": false,
        }
    }
}

3. Check your build and install commands in Vercel UI

Go to Settings -> General tab in your project in Vercel UI and verify commands:

Build and Install

The build command should be:

cd ../../ && pnpm run build --filter=web...

And install command (assuming that you're using pnpm)

pnpm install

4. Check "Root Directory" in Vercel UI

Go to Settings -> General tab in your project in Vercel UI and verify the project path:

Project Root

Verify that it's representing your next.js project path: apps\web

Dreg answered 18/3, 2023 at 9:28 Comment(1)
I love you, this helped a lot ❤️Persuade
I
4

Overriding the build folder fixed my issue.

enter image description here

Ibidem answered 9/2, 2023 at 6:1 Comment(0)
I
2

I also ran into this error because the root directory of my app was not in the top-level directory of my Git repository, so Vercel was unable to find the .next folder.

I fixed it by going to the Vercel dashboard for my Vercel project, then -> Settings -> General and setting Root Directory to the subdirectory path to my application: enter image description here

Inglebert answered 30/3, 2022 at 18:16 Comment(0)
B
2

Issue was we were using 'latest' in package.json for next version. I fixed it to previous version of nextjs which is 12.3.1 for us seems to have fixed the deployment for now.

But still waiting for vercel support for best way to update nextjs version in deployment for vercel or is it some sort of bug their end.

Burks answered 3/11, 2022 at 0:7 Comment(0)
U
0

In my case, make sure please if the folder within the project is called "web", the json name inside should be "web"!

Unitary answered 15/11, 2022 at 17:26 Comment(0)
D
0

In my case I had a few errors in my files

Error: `'` can be escaped with `'`, `‘`, `'`, `’`.  react/no-unescaped-entities

Which were being hidden in the Vercel build log because I forgot I had the following in next.config.js

eslint: {
  ignoreDuringBuilds: true,
}

Which just showed me the error you have instead of the actual reason it failed.

Enabling eslint indirectly solved my issue as it led me to find the real error.

Daphne answered 19/11, 2022 at 6:7 Comment(0)
U
0

I was getting same error in case for nx intergrated app. I changed the settings in the vercel project and then it worked

These were the settings that worked

Vercel settings that worked for next js app in nx integrated app

Unravel answered 4/3, 2023 at 14:26 Comment(0)
S
0

Been plagued by this for a few weeks. I sent this issue over to Vercel support.

I experienced this with multiple projects being deployed to Vercel managed by a Turborepo monorepo.

The reply I got back was that for all tasks in the turbo.json file, an outputs key must exist that contains [".next/**", "!.next/cache/**"] among any other files you may have.

Example below:

{
  "$schema": "https://turbo.build/schema.json",
  "globalEnv": [
     ...,
  ],
  "tasks": {
    "build": {
      "outputs": [".next/**", "!.next/cache/**"],
      ...
    },
    "test": {
      "outputs": ["coverage/**", ".next/**", "!.next/cache/**"],
      ...
    },
...
}

Updated the turbo.json and the issue finally went away, this has something to do with the top level caching. Builds are down from 1m30s to 30s.

Sackcloth answered 26/7 at 14:19 Comment(0)
R
-1
  1. Run npm run build (check all files in builded folder)
  2. Create .next folder and move all files from build folder to .next
  3. Commit your .next folder to vercel or maybe git.
Rhapsodist answered 8/2, 2022 at 16:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.