Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Specify MDX version to install #2133

Closed
aryanjha256 opened this issue Feb 13, 2022 · 6 comments · Fixed by #2288
Closed

docs: Specify MDX version to install #2133

aryanjha256 opened this issue Feb 13, 2022 · 6 comments · Fixed by #2288
Labels
prerelease This change is available in a prerelease.

Comments

@aryanjha256
Copy link

aryanjha256 commented Feb 13, 2022

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

@lachlanjc
Copy link
Member

Yep, unfortunately this is a known issue, we just haven't figured out the resolution: #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 lachlanjc changed the title I am using next.js and this happened docs: Specify MDX version to install Feb 13, 2022
@jacksonbrim
Copy link

jacksonbrim commented May 13, 2022

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

@john20xdoe
Copy link

john20xdoe commented Jun 7, 2022

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

@hasparus
Copy link
Member

hasparus commented Jun 7, 2022

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

@john20xdoe
Copy link

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

@moimikey
Copy link

moimikey commented Aug 30, 2022

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

@hasparus hasparus added the prerelease This change is available in a prerelease. label Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prerelease This change is available in a prerelease.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants