-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Error [ERR_REQUIRE_ESM]: require() of ES Module #216
Comments
thank you for replying. I tested your suggestion. but when I changed
I want to use like below. const Markdown = dynamic(
() => import("@uiw/react-markdown-preview").then((mod) => mod.default),
{ ssr : true }
); I want to import |
@lhjeong60 The code highlight library does not support |
Ok, then I'll find another way. Thank you |
If you has a problem in the future with "Error [ERR_REQUIRE_ESM]: require() of ES Module", just follow this code, in my case specially when I try to import a react-markdown-preview on my code. That's work to me, using this code below and const MarkdownPreview = dynamic(
() => import("@uiw/react-markdown-preview").then((mod) => mod.default),
{ ssr: false }
); Of course with SSR false. |
This is such a frustrating issue. Wasn't able to solve in Nextjs with typescript |
Hi, I m using Next.js v13 and I already use
next-remove-imports
, And I also check issue #184.In my project, I have to render markdown in server side.
I got below Error when I import
react-markdown-preview
directly or dynamic import (next/dynamic) with ssr option as true.error - Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/react-markdown/index.js from .../node_modules/@uiw/react-markdown-preview/lib/index.js not supported.
In my opinion, this error is caused by module between CommonJS and ES Module.
#184 and I both import out of browser which is electron, node.js, maybe they use CommonJS module System.
In
node_modules/@uiw/react-markdown-preview/lib/index.js
, some project was imported by CommonJS, but I Guess, they export ES module system only.Now, I solve this problem by changing
require()
to(async () => await import())()
innode_modules/@uiw/react-markdown-preview/lib/index.js
But I think this way is a bad idea.
Has anyone solved this problem?
The text was updated successfully, but these errors were encountered: