Error [ERR_REQUIRE_ESM]: require() of ES Module
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- next.js, node.js, react, typescript
- Domain
- frontend
Research direction
Reproduce the server-side import with Next.js v13 and inspect node_modules/@uiw/react-markdown-preview/lib/index.js alongside the react-markdown ESM error. Confirm that the package can be imported during SSR without editing node_modules; the issue does not name a repository source file or test to run.
Written by the indexing model from the issue text.
Description
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())() in node_modules/@uiw/react-markdown-preview/lib/index.js
But I think this way is a bad idea.
Has anyone solved this problem?
- Dominant language
- TypeScript
- Stars
- 350
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from uiwjs/react-markdown-preview
-
Difficulty 3/5 1-2 days Newbie friendliness 62/100
uiwjs/react-markdown-preview#292 ·
-
Error when evaluating SSR module virtual:react-router/server-build: Unknown file extension ".css"Open
Difficulty 3/5 1-2 days Newbie friendliness 30/100
uiwjs/react-markdown-preview#288 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
uiwjs/react-markdown-preview#287 · 1 comment ·
-
Bundle too heavy?Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
uiwjs/react-markdown-preview#286 · 1 comment ·
-
Strikethrough Error!Open
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
uiwjs/react-markdown-preview#284 · 1 comment ·
All issues in uiwjs/react-markdown-preview
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ehmpathy/rhachet-roles-bhrain#586 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
OHDSI/Data2Evidence#3496 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/rocketmq-dashboard#5594 ·
Maintainers usually reply within 3 days
-
react-doctor severity:warning tech-debt
Difficulty 1/5 Under an hour Newbie friendliness 88/100
digidem/comapeo-cloud-app#418 ·
Maintainers usually reply within 1 day