Next.js Discord

Discord Forum

build error about client component in app/_util

Unanswered
Dunker posted this in #help-forum
Open in Discord
DunkerOP
I just update nextjs v14 and got error when build, here's the error message

Failed to compile.

./app\_util\server\helper\error\error.ts
ReactServerComponentsError:

./app/_util/server/helper/error/error.ts must be a Client Component. Add the "use client" directive the top of the file to resolve this issue.
Learn more: https://nextjs.org/docs/getting-started/react-essentials#client-components

Import path:
  ./app\_util\server\helper\error\error.ts
  ./app\_util\server\helper\error\index.ts
  ./app\_util\server\helper\index.ts
  ./app\api\auth\route.ts


app/_util/helper/error/error.ts
const createError = (message: string): Errors => {
  return new Error(message) as Errors;
};

export const isErrors = (err: unknown): err is Errors => {
  return err instanceof Error
    ? "name" in err && typeof err.name === "string"
    : false;
};

export const databaseError = (message: string): Errors => {
  const error = createError(message);
  error.name = "DatabaseError";
  return error;
};


In my understanding, the _folder in the app will not have routing and routing. Why does _util need to be marked with 'use client'? Moreover, I import it in app/api/auth/route.ts, not in the client component. , is this a bug?

0 Replies