Next.js Discord

Discord Forum

Build Error

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Avatar
Saltwater CrocodileOP
PS E:\...> npm run build

> ...@0.1.0 build
> next build

   ▲ Next.js 15.0.4
   - Environments: .env.local

   Creating an optimized production build ...
 ✓ Compiled successfully
   Linting and checking validity of types  ..Failed to compile.

.next/types/app/layout.ts:12:13
Type error: Type 'OmitWithTag<typeof import("E:/.../app/layout"), "metadata" | "default" | "config" | "generateStaticParams" | "revalidate" | "dynamic" | "dynamicParams" | "fetchCache" | ... 6 more ... | "experimental_ppr", "">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'robotoFont' is incompatible with index signature.
    Type 'NextFontWithVariable' is not assignable to type 'never'.

  10 |
  11 | // Check that the entry is a valid entry
> 12 | checkFields<Diff<{
     |             ^
  13 |   default: Function
  14 |   config?: {}
  15 |   generateStaticParams?: Function

4 Replies

Avatar
Saltwater CrocodileOP
layout.tsx
import { ThemeProvider } from "@/components/theme-provider";
import type { Metadata } from "next";
import { Noto_Sans_JP, Roboto } from "next/font/google";
import "./globals.css";

export const robotoFont = Roboto({
  subsets: ["latin"],
  weight: ["100", "300", "400", "500", "700", "900"],
  variable: "--font-roboto",
});

export const notoSansJp = Noto_Sans_JP({
  subsets: ["latin"],
  weight: ["100", "200", "300", "400", "500", "600", "700", "800", "900"],
  variable: "--font-noto-sans-jp",
});

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body
        className={`w-full h-dvh ${robotoFont.variable} ${notoSansJp.variable} antialiased`}
      >
        <ThemeProvider
          attribute="class"
          defaultTheme="dark"
          enableSystem
          disableTransitionOnChange
        >
          {children}
        </ThemeProvider>
      </body>
    </html>
  );
}
package.json
{
  "name": "...",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev --turbopack",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "class-variance-authority": "^0.7.1",
    "clsx": "^2.1.1",
    "lucide-react": "^0.468.0",
    "next": "15.0.4",
    "next-themes": "^0.4.4",
    "react": "^19.0.0",
    "react-dom": "^19.0.0",
    "tailwind-merge": "^2.5.5",
    "tailwindcss-animate": "^1.0.7"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^19",
    "@types/react-dom": "^19",
    "eslint": "^8",
    "eslint-config-next": "15.0.4",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}
Avatar
@Alfonsus Ardani cant have non-conventional exports in layout.tsx and page.tsx. remove `export` in each of the fonts
Avatar
Saltwater CrocodileOP
I was able to build by removing export. Thank you very much!