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.

Build error occurred: require() of ES modules is not supported

See original GitHub issue

Hello,

I followed the tutorial to install Umami and I have the following error when I try to build (npm run build):

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\Benjamin\Documents\Développement\umami\node_modules\d3-array\src\index.js
require() of ES modules is not supported.
require() of C:\Users\Benjamin\Documents\Développement\umami\node_modules\d3-array\src\index.js from C:\Users\Benjamin\Documents\Développement\umami\node_modules\d3-geo\dist\d3-geo.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\Benjamin\Documents\Développement\umami\node_modules\d3-array\package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1080:13)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at C:\Users\Benjamin\Documents\Développement\umami\node_modules\d3-geo\dist\d3-geo.js:3:81
    at Object.<anonymous> (C:\Users\Benjamin\Documents\Développement\umami\node_modules\d3-geo\dist\d3-geo.js:6:2)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32) {
  type: 'NodeError',
  code: 'ERR_REQUIRE_ESM'
}

I have the same problem on two different environments. Node v14.17.0 Npm 7.16.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:13

github_iconTop GitHub Comments

12reactions
mIcHyAmRaNecommented, Jun 8, 2021

this is due to the new d3-array update

so to resolve the build error, downgrade d3-array:

  • add "d3-array": "^2.12.1" to "devDependencies" in packages.json
  • then run npm install
2reactions
mikecaocommented, Jun 10, 2021

Looks like this is an issue with Next.js, https://github.com/vercel/next.js/issues/23725

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
I'm trying to make a Discord bot that just says if someone is online on the game. However I keep getting this message:...
Read more >
require() of ES modules is not supported · Issue #43833 - GitHub
An unhandled exception occurred: Must use import to load ES Module: /Users/jeb/angular-builders/packages/custom-webpack/dist/browser/index.js ...
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 modules is not supported - You.com - You.com
Strict. Open links in a new tab. Make Default · Customize search with apps ... Error: require() of ES modules is not supported...
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
This code works in CommonJS modules, but will fail in ES modules because relative import paths need to use extensions. As a result,...
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