Next.js Discord

Discord Forum

fs/promises not resolving in server component

Answered
Giant panda posted this in #help-forum
Open in Discord
Giant pandaOP
My page.tsx component is clearly a server component, but when I run the web app one of the node-only dependencies I'm importing is not resolving, as if it were a client component. I just need to fetch some data from the file system securely on the server and then pass it down as props to client components:

export default async function Home({ params }: PageProps) {
  const lessonData = getLessonData(params)
  if (lessonData == null) return notFound()

  return (
    <ContextProviders
      courseContext={{
        currentCourseData: await getCourseData(params.course),
        coursesData: await getAllCourses(),
      }}
    >
      <Navbar />
      <LessonContents
        content={lessonData.contents}
        lessonId={parseInt(params.lesson)}
        courseId={params.course}
      />
    </ContextProviders>
  )
}


An image of the error is attached; does anyone know what's going on?
Answered by Giant panda
Just figured it out; I should have read the stack trace: I was importing a function defined in page.tsx from icon.tsx, which had the edge runtime enabled
View full answer

1 Reply

Giant pandaOP
Just figured it out; I should have read the stack trace: I was importing a function defined in page.tsx from icon.tsx, which had the edge runtime enabled
Answer