theme-ui icon indicating copy to clipboard operation
theme-ui copied to clipboard

docs: Specify MDX version to install

Open aryanjha256 opened this issue 3 years ago • 5 comments
trafficstars

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.

Screenshot 2022-02-13 191552

aryanjha256 avatar Feb 13 '22 13:02 aryanjha256

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.

lachlanjc avatar Feb 13 '22 14:02 lachlanjc

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

jacksonbrim avatar May 13 '22 06:05 jacksonbrim

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. image

john20xdoe avatar Jun 07 '22 05:06 john20xdoe

@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 avatar Jun 07 '22 16:06 hasparus

@hasparus ooh, didn't realize there's an option for that. Thanks

john20xdoe avatar Jun 08 '22 02:06 john20xdoe

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

moimikey avatar Aug 30 '22 19:08 moimikey