Help fix production error about new next js awaiting props
Answered
Tomistoma posted this in #help-forum
TomistomaOP
help me fix these errors
Answered by joulev
import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import { notFound } from "next/navigation";
import { routing } from "@/i18n/routing";
import { Locales } from "@/types";
import "@/styles/globals.css";
export default async function LocaleLayout({
children,
params,
}: {
children: React.ReactNode;
- params: { locale: string };
+ params: Promise<{ locale: string }>;
}) {
const { locale } = await params;
// Ensure that the incoming `locale` is valid
if (!routing.locales.includes(locale as Locales)) {
notFound();
}
// Providing all messages to the client
// side is the easiest way to get started
const messages = await getMessages();
return (
<html lang={locale}>
<body>
<NextIntlClientProvider messages={messages}>
{children}
</NextIntlClientProvider>
</body>
</html>
);
}
13 Replies
TomistomaOP
Creating an optimized production build ...
✓ Compiled successfully
Linting and checking validity of types .Failed to compile.
.next/types/app/[locale]/layout.ts:34:31
Type error: Type '{ children: ReactNode; params: { locale: string; }; }' does not satisfy the constraint 'LayoutProps'.
Types of property 'params' are incompatible.
Type '{ locale: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
32 |
33 | // Check the prop type of the entry function
> 34 | checkFields<Diff<LayoutProps, FirstArg<TEntry['default']>, 'default'>>()
| ^
35 |
36 | // Check the arguments and return type of the generateMetadata function
37 | if ('generateMetadata' in entry) {
Static worker exited with code: 1 and signal: null
import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import { notFound } from "next/navigation";
import { routing } from "@/i18n/routing";
import { Locales } from "@/types";
import "@/styles/globals.css";
export default async function LocaleLayout({
children,
params,
}: {
children: React.ReactNode;
params: { locale: string };
}) {
const { locale } = await params;
// Ensure that the incoming `locale` is valid
if (!routing.locales.includes(locale as Locales)) {
notFound();
}
// Providing all messages to the client
// side is the easiest way to get started
const messages = await getMessages();
return (
<html lang={locale}>
<body>
<NextIntlClientProvider messages={messages}>
{children}
</NextIntlClientProvider>
</body>
</html>
);
}
import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import { notFound } from "next/navigation";
import { routing } from "@/i18n/routing";
import { Locales } from "@/types";
import "@/styles/globals.css";
export default async function LocaleLayout({
children,
params,
}: {
children: React.ReactNode;
- params: { locale: string };
+ params: Promise<{ locale: string }>;
}) {
const { locale } = await params;
// Ensure that the incoming `locale` is valid
if (!routing.locales.includes(locale as Locales)) {
notFound();
}
// Providing all messages to the client
// side is the easiest way to get started
const messages = await getMessages();
return (
<html lang={locale}>
<body>
<NextIntlClientProvider messages={messages}>
{children}
</NextIntlClientProvider>
</body>
</html>
);
}
Answer
TomistomaOP
@joulev
Creating an optimized production build ...
uncaughtException [Error: EPERM: operation not permitted, open 'D:\Devolepment Folder 'dont touch'\Projects\My own\LightByte\light-byte\.next\trace'] {
errno: -4048,
code: 'EPERM',
syscall: 'open',
path: "D:\\Devolepment Folder 'dont touch'\\Projects\\My own\\LightByte\\light-byte\\.next\\trace"
}
what is that ??
@Tomistoma <@484037068239142956>
Creating an optimized production build ...
uncaughtException [Error: EPERM: operation not permitted, open 'D:\Devolepment Folder 'dont touch'\Projects\My own\LightByte\light-byte\.next\trace'] {
errno: -4048,
code: 'EPERM',
syscall: 'open',
path: "D:\\Devolepment Folder 'dont touch'\\Projects\\My own\\LightByte\\light-byte\\.next\\trace"
}
no idea, seems like some windows issues, i don't use windows.
try deleting the
try deleting the
.next
folder and rerun the build againTomistomaOP
alright
same errors
@joulev
@Tomistoma same errors
it's not
{ locale: Promise<string> }
it is Promise<{ locale: string }>
TomistomaOP
Oh! if forgot to commit the new changes, thanks!
@Tomistoma <@484037068239142956>
Creating an optimized production build ...
uncaughtException [Error: EPERM: operation not permitted, open 'D:\Devolepment Folder 'dont touch'\Projects\My own\LightByte\light-byte\.next\trace'] {
errno: -4048,
code: 'EPERM',
syscall: 'open',
path: "D:\\Devolepment Folder 'dont touch'\\Projects\\My own\\LightByte\\light-byte\\.next\\trace"
}
just an advice, avoid spaces in folder names, especially in windows
@Yi Lon Ma just an advice, avoid spaces in folder names, especially in windows
TomistomaOP
Alright, thanks for your advice!