Next.js Discord

Discord Forum

Error: Can't find module <path>/index.mjs#Accordion#Root

Unanswered
Southern African anchovy posted this in #help-forum
Open in Discord
Southern African anchovyOP
Hi, I'm trying to test my component library to supports SSR in next.js page.
in index.mjs this is how i export things (e.g Accordion component index file):
export const Accordion = {
  Root: AccordionRoot,
  Item: AccordionItem,
  ItemHeader: AccordionItemHeader,
  ItemTrigger: AccordionItemTrigger,
  ItemContent: AccordionItemContent,
}

and then import and use it:
import { Accordion } from 'mylib/accordion'
...
<Accordion.Root>
...

I want to understand what does next.js resolver do with the hashtag of the file <path>/index.mjs#Accordion#Root

IMPORTANT NOTES:
- the error only shows if i dont use 'use client'; directives
- its also works fine if in index.mjs file i export it like this:
export {
  AccordionRoot as Root,
  AccordionItem as Item,
  AccordionItemHeader as ItemHeader,
  AccordionItemTrigger as ItemTrigger,
  AccordionItemContent as ItemContent,
}

and import it like this:
import * as Accordion from 'mylib/accordion'
...
<Accordion.Root>
...


Full error message:
Unhandled Runtime Error
Error: Could not find the module "/Users/kao/Workspace/Github/ohra-ui/examples/ssr-supports/node_modules/.pnpm/<my-component-lib>/dist/components/accordion/index.mjs#Accordion#Root" in the React Client Manifest. This is probably a bug in the React Server Components bundler.


Thanks for the help

0 Replies