Skip to content

Instantly share code, notes, and snippets.

@devilelephant
Last active April 30, 2024 19:57
Show Gist options
  • Save devilelephant/a9da0be914fb61b7f7c7233b6825f6c6 to your computer and use it in GitHub Desktop.
Save devilelephant/a9da0be914fb61b7f7c7233b6825f6c6 to your computer and use it in GitHub Desktop.
Next.js 14 MDX fix when running --turbo dev server
import nextMDX from "@next/mdx";
/** @type {import('next').NextConfig} */
const nextConfig = {
pageExtensions: ["js", "jsx", "ts", "tsx", "mdx"],
experimental: {
mdxRs: true
},
};
const withMDX = nextMDX({
extension: /\.mdx?$/
});
export default withMDX(nextConfig);
@devilelephant
Copy link
Author

This solves the "Error: not an ecmascript module" error when trying to run MDX on Node.js 14 with the --turbo flag on the dev server.

main fix was the mdxRs:true experimental flag:

  experimental: {
    mdxRs: true
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment