Build error occurred: require() of ES modules is not supported
See original GitHub issueHello,
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:
- Created 2 years ago
- Reactions:5
- Comments:13
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this is due to the new d3-array update
so to resolve the build error, downgrade
d3-array
:"d3-array": "^2.12.1"
to"devDependencies"
inpackages.json
npm install
Looks like this is an issue with Next.js, https://github.com/vercel/next.js/issues/23725