Open lhjeong60 opened 1 year ago
thank you for replying.
I tested your suggestion. but when I changed ssr
option of dynamic import as true, I got same error in codesandbox.
(In my project, I already use next-remove-imports
and dynamic import)
I want to use like below.
const Markdown = dynamic(
() => import("@uiw/react-markdown-preview").then((mod) => mod.default),
{ ssr : true }
);
I want to import react-markdown-preview
in server side. Is it possible?
@lhjeong60 The code highlight library does not support ssr
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 import dynamic from 'next/dynamic'
:
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?