setup documentation does not works
I would love to use nextra but despite following the documentation I am facing an error :
Build Error
Module not found: Can't resolve 'next-mdx-import-source-file'
./node_modules/nextra/dist/client/setup-page.js (3:1)
Module not found: Can't resolve 'next-mdx-import-source-file'
1 | "use no memo";
2 | import { jsx } from "react/jsx-runtime";
> 3 | import { useMDXComponents as getMDXComponents } from "next-mdx-import-source-file";
| ^
4 | import { createElement } from "react";
5 | const Wrapper = getMDXComponents().wrapper;
6 | function HOC_MDXWrapper(MDXContent, hocProps) {
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/page.mdx
i think there is something missing but since I don't know what I cannot use your library.
where do you put mdx-components file?
With nextjs version 15.5.2 i had the same issue. I moved the mdx-components.tsx into the root dir, still the same error.
The error came from my app/docs/[[...mdxPath]]/page.jsx.
The import was import { useMDXComponents } from "@/mdx-components";
I created a JS shim in root dir mdx-components.js and added export { useMDXComponents } from './mdx-components.tsx';
This seems to help to resolve the correct file.
Then i changed the import in app/docs/[[...mdxPath]]/page.jsx from:
import { useMDXComponents } from "@/mdx-components";
to:
import { useMDXComponents } from 'next-mdx-import-source-file';
This worked for me to fix this error.