theme-ui
theme-ui copied to clipboard
docs: Specify MDX version to install
Server Error
Error: require() of ES Module C:\Users\ARYAN\Desktop\itsaryan\node_modules\@mdx-js\react\index.js from C:\Users\ARYAN\Desktop\itsaryan\node_modules\@theme-ui\mdx\dist\theme-ui-mdx.cjs.dev.js not supported. Instead change the require of index.js in C:\Users\ARYAN\Desktop\itsaryan\node_modules\@theme-ui\mdx\dist\theme-ui-mdx.cjs.dev.js to a dynamic import() which is available in all CommonJS modules.
This error happened while generating the page. Any console logs will be displayed in the terminal window.

Yep, unfortunately this is a known issue, we just haven't figured out the resolution: https://github.com/system-ui/theme-ui/issues/2023
We don't yet support MDX v2, which was recently released. The fix is to downgrade @mdx-js/react to the latest version of v1, & you should be good to go.
Can you please update the documentation in the ReadMe and on the website so that the info reflects installing mdx-js/react v1? This project is used in a popular, but older tutorial that's causing some headaches for newbies.
npm install theme-ui @emotion/react @mdx-js/react@1
For yarn:
yarn add theme-ui @emotion/react @mdx-js/react@1
Notes (since the original title indicates next.js was being used):
Downgrading to the v1 of mdx-js (1.6.22?) makes it depend only up to react@17.
So those who already use react@18 and above (for example, users of latest NextJS), will not be able to use the downgrade workaround unless they also downgrade the other.

@john20xdoe Please use --legacy-peer-deps for now. MDX 1 doesn't depend on React 17, it was just written at the time React 17 was the newest version.
@hasparus ooh, didn't realize there's an option for that. Thanks
these feels like a bandaid fix. i use projen and by default when it tries to install my node dependencies, it errors on necessitating --legacy-peer-deps which is bothersome. is there a long-term workaround coming soon?
my current solution is throwing this into .npmrc, so the flag isn't explicitly needed for CI and newly onboarded devs who would otherwise run into this error:
legacy-peer-deps=1