question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error [ERR_REQUIRE_ESM]: require() of ES Module

See original GitHub issue

Describe the Bug

I’m using React Flow with Remix, and getting the following error when running example code:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/user/Emerge/flow/node_modules/.pnpm/react-flow-renderer@10.0.0-next.51_react-dom@17.0.2+react@17.0.2/node_modules/react-flow-renderer/dist/esm/index.js from /Users/user/Emerge/flow/build/index.js not supported. Instead change the require of /Users/user/Emerge/flow/node_modules/.pnpm/react-flow-renderer@10.0.0-next.51_react-dom@17.0.2+react@17.0.2/node_modules/react-flow-renderer/dist/esm/index.js in /Users/user/Emerge/flow/build/index.js to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/Users/user/Emerge/flow/build/index.js:395:43) at /Users/user/Emerge/flow/node_modules/.pnpm/@remix-run+serve@1.2.3_react-dom@17.0.2+react@17.0.2/node_modules/@remix-run/serve/index.js:40:17 at Layer.handle [as handle_request] (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/layer.js:95:5) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:137:13) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:131:14) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:131:14) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:131:14) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:131:14) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:131:14) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:131:14) at Route.dispatch (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/layer.js:95:5) at /Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:281:22 at param (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:360:14) at param (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:371:14) at Function.process_params (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:416:3) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:275:10) at logger (/Users/user/Emerge/flow/node_modules/.pnpm/morgan@1.10.0/node_modules/morgan/index.js:144:5) at Layer.handle [as handle_request] (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:323:13) at /Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:341:12) at next (/Users/user/Emerge/flow/node_modules/.pnpm/express@4.17.3/node_modules/express/lib/router/index.js:275:10) at SendStream.error (/Users/user/Emerge/flow/node_modules/.pnpm/serve-static@1.14.2/node_modules/serve-static/index.js:121:7) at SendStream.emit (node:events:390:28) at SendStream.error (/Users/user/Emerge/flow/node_modules/.pnpm/send@0.17.2/node_modules/send/index.js:270:17) at SendStream.onStatError (/Users/user/Emerge/flow/node_modules/.pnpm/send@0.17.2/node_modules/send/index.js:421:12) at next (/Users/user/Emerge/flow/node_modules/.pnpm/send@0.17.2/node_modules/send/index.js:763:28) at /Users/user/Emerge/flow/node_modules/.pnpm/send@0.17.2/node_modules/send/index.js:771:23 at FSReqCallback.oncomplete (node:fs:198:21)

Your Example Website or App

https://stackblitz.com/edit/node-xkwl6v?file=app%2Froutes%2Findex.tsx

Steps to Reproduce the Bug or Issue

See stackblitz. Just install v10 branch and get any example loading

Expected behavior

As a developer I except the compiler to be happy so that there is peace in the world

Screenshots or Videos

No response

Platform

  • OS: MacOS latest
  • Browser: Chrome latest
  • Version: v10

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
moklickcommented, Apr 11, 2022

I added an UMD build in v10.1.0. React Flow works with Stackblitz and Remix now.

1reaction
abc3354commented, Mar 31, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
I figured it out. I just had to downgrade node-fetch to 2.6.6, as the higher versions only use ESM, which caused a lot...
Read more >
Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The error [ERR_REQUIRE_ESM]: require() of ES Module not supported. Instead change the require of index.js to a dynamic import() which is available in...
Read more >
require() of ES Module fix-path/index.js from main.ts ... - GitHub
App threw an error during load Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/manuel/src/electron-react-boilerplate/node_modules/fix-path/index.js ...
Read more >
ERR_REQUIRE_ESM - DEV Community ‍ ‍
The short answer — es module brings top-level await, but require has no idea how to deal with it. Detailed explanation — announcing...
Read more >
gulp error [err_require_esm]: require() of es module - You.com
If your environment supports ES Modules, you should try to convert the require() import to ESM. Favicon for stackoverflow.com. Getting ` Error [ERR_REQUIRE_ESM]` ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found