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.

Server Side Rendering Error: Error [ERR_REQUIRE_ESM]: require() of ES Module

See original GitHub issue

Environment


  • Operating System: Windows_NT
  • Node Version: v16.10.0
  • Nuxt Version: 2.16.0-27226092.034b9901
  • Package Manager: npm
  • Bundler: Webpack
  • User Config: buildModules
  • Runtime Modules: -
  • Build Modules: @nuxt/bridge@3.0.0-27235989.d52b1e8

Describe the bug

When i try to run my Nuxt 2 project with Nuxt Bridge it doesnโ€™t work. I tried to remove all unnecessary stuff but I still get the same error on run

Server Side Rendering Error: Error [ERR_REQUIRE_ESM]: require() of ES Module D:\projects\nuxt3Test\node_modules\node-fetch\sr
c\index.js from D:\projects\nuxt3Test\.nuxt\dist\server\server.js not supported.
Instead change the require of index.js in D:\projects\nuxt3Test\.nuxt\dist\server\server.js to a dynamic import() which is av
ailable in all CommonJS modules.

Whole code to reproduce the error is here https://github.com/PayteR/Nuxt3Test

When I tried to install fresh Nuxt 2 and then add Bridge, then it runs all good.

Reproduction

Download code from here https://github.com/PayteR/Nuxt3Test install dependencies and run

Additional context

No response

Logs

No response

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
kolchurinvvcommented, Apr 13, 2022

I think i have a similar issue:

npm run dev

> package_name@1.0.3 dev
> nuxt


   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
   โ”‚                                       โ”‚
   โ”‚   Nuxt @ v2.16.0-27226092.034b9901    โ”‚
   โ”‚                                       โ”‚
   โ”‚   โ–ธ Environment: development          โ”‚
   โ”‚   โ–ธ Rendering:   server-side          โ”‚
   โ”‚   โ–ธ Target:      static               โ”‚
   โ”‚                                       โ”‚
   โ”‚   Listening: http://localhost:3000/   โ”‚
   โ”‚                                       โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โ„น Preparing project for development                                                                                                      18:19:57
โ„น Initial build may take a while                                                                                                         18:19:57
โ„น Discovered Components: .nuxt/components/readme.md                                                                                      18:19:57
โœ” Builder initialized                                                                                                                    18:19:57
โœ” Nuxt files generated                                                                                                                   18:19:58

โœ” Client
  Compiled successfully in 32.84s

โœ” Server
  Compiled successfully in 32.52s

โ„น Waiting for file changes                                                                                                               18:20:34
โ„น Memory usage: 234 MB (RSS: 582 MB)                                                                                                     18:20:34
โ„น Listening on: http://localhost:3000/                                                                                                   18:20:34
โœ” Nitro built in 332 ms                                                                                                                  18:20:34
Server Side Rendering Error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/vladimir/Dev_Projects/project_folder/domains/domain_name/.nuxt/dist/server/server.js
    at new NodeError (internal/errors.js:322:7)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/Users/vladimir/Dev_Projects/project_folder/domains/domain_name/.nuxt/dist/server/server.cjs:1:18)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32) {
  code: 'ERR_REQUIRE_ESM'
}
1reaction
danielroecommented, Oct 26, 2021

Iโ€™m closing this as it seems resolved.

@Razunter Try running:

yarn add --dev @nuxt/bridge@npm:@nuxt/bridge-edge@latest

(If you drop the version tag off the end youโ€™ll get the error youโ€™re seeing from yarn.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

require() of ES Module while using SSR (Inertiajs) - Stack ...
But just while running the final node process ( node public/js/ssr.js ), I'm getting this error: Error [ERR_REQUIRE_ESM]: require() of ES Moduleย ...
Read more >
Error: Must use import to load ES Module ยท Issue #25454
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\test-nextjs\.next\server\pages\_document.js require() of ES modules is notย ...
Read more >
How to Bypass ES Modules Errors in Next.js with Dynamic ...
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/package require() of ES modules is not supported. ES module file as itย ...
Read more >
Server-side rendering (SSR) with Angular Universal
The route comes from the client's request to the server. Each request results in the appropriate view for the requested route. The renderModule()...
Read more >
Server Side Rendering Frameworks with @arcgis/core - Esri
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: โ€ฆ require() of ES modules is not supported. โ€ฆ is an ES module file...
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