Next.js Discord

Discord Forum

Error in deploy

Unanswered
Silver Fox posted this in #help-forum
Open in Discord
Silver FoxOP
Hi, I'm studying the framework and completed the acme-dashboard course.
Excellent stuff by the way, but I can't deploy the finished project to Vercel. I receive the following error in build:
Type error: Cannot find name 'Metadata'.
This is my first contact with Typescript too, but looks like the Metadata type isn't defined, right? Why this error doesn't appear in dev script?

22 Replies

American Crow
Did you try to buildlocally? npm run build
should get the same error there
Silver FoxOP
mmm.. yeah, same problem
American Crow
I didn't do the course but they probably did some setting for the devenvironment to ignore Typescript error to make it easier on the beginners.

You can go two routes:
a): Ignore Typescript errors everywhere (build and dev, local and production). This is obviously not great but since you are learning, you may want to defer Typescript to a later point in time.
In your next.config.js
module.exports = {
  typescript: {
    // !! WARN !!
    // Dangerously allow production builds to successfully complete even if
    // your project has type errors.
    // !! WARN !!
    ignoreBuildErrors: true,
  },
}

I mean you see the warnings. Only for learning purposes not a real production app.

b) Setup something like eslint to get the errors in your IDE (vscode or whatever you use) and fix the Types
Screenshot of a Type Error in vscode:
//Edit
Alomost forgot. Your Error particular you most likely just forgot to import the Type "Metadata"
import { type Metadata } from "next"
// Edit2:
In general always first build locally (and fix errors) before pushing to Vercel (or whereever you host)
Silver FoxOP
i'm also using vscode and getting the error in IDE linter.
i don't think it's a good idea ignore errors although I have done it...
The Metadata interface is already imported in app layout
American Crow
you have the error in /dashboard/invoices/[id]/edit/page.tsx
Silver FoxOP
yes, and in other pages too
but that's how the course teaches
import only in the app layout
American Crow
Hm thats not true give me the link where the course says that maybe you misunderstod
Silver FoxOP
btw, the metadata pages its fully working on dev script
i just cant build
American Crow
yea cause type errors don't stop you in dev
would be annyoing if the dev server stops every time you didnt define type (yet)
I don't see in the course where it says you only have to import metadata type in the layouts
i think you misunderstood something
you can use metadata in the layout and every page below it will 'inherit' that meta data that is true
but if you define more metadata within a child (like you did) in /dashboard/invoices/[id]/edit/page.tsx you have to import the type there as well
Silver FoxOP
mm, i assumed wrong
thank you for your help