Cannot compile mdxjsEsm
node
#2224
Replies: 4 comments 24 replies
-
If I change
|
Beta Was this translation helpful? Give feedback.
-
Could you put some text content in the mdx file and try again? |
Beta Was this translation helpful? Give feedback.
-
Remove |
Beta Was this translation helpful? Give feedback.
-
It appears you’re trying to load both markdown and MDX files. You want to use a rehype plugin for markdown files, but not for MDX. This is possible by specifying two distinct MDX integrations, one for markdown, and one for MDX. import createMDXPlugin from '@next/mdx'
import rehypeRaw from 'rehype-raw'
const withMDX = createMDXPlugin({
extension: /\.mdx$/,
options: {
// These options apply to .mdx fles only
providerImportSource: '@mdx-js/react',
rehypePlugins: [],
remarkPlugins: [],
},
})
const withMarkdown = createMDXPlugin({
extension: /\.md$/,
options: {
// These options apply to .md fles only
providerImportSource: '@mdx-js/react',
rehypePlugins: [rehypeRaw],
remarkPlugins: [],
},
})
const nextConfig = withMDX(withMarkdown({
compiler: {
styledComponents: true,
},
pageExtensions: ['mdx', 'md', 'tsx', 'ts'],
poweredByHeader: false,
// reactStrictMode: true,
trailingSlash: false,
}))
export default nextConfig |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am in Next.js with this config:
I have installed the 3 modules listed here. I can successfully render some MDX content which I import into a next.js page. But when I try to load a
pages/example.mdx
file directly as a Next.js page, it throws this error:Searching the web for
mdxjsEsm
yields nothing, surprisingly.All I have in my mdx file is this:
Any ideas? Layout renders the Next.js head
import NextHead from 'next/head'
, so maybe that is causing issues? I don't know, could use some help.Beta Was this translation helpful? Give feedback.
All reactions