Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
See original GitHub issueHi, I’m having an issue importing the library using Next.js.
NPM version: 6.14.11 Node version: v14.16.0 Next.js version: v9.4
Error:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/fraps/Coding/looselyhub/looselyhub/node_modules/direction/index.js
require() of ES modules is not supported.
require() of /home/fraps/Coding/looselyhub/looselyhub/node_modules/direction/index.js from /home/fraps/Coding/looselyhub/looselyhub/node_modules/@glideapps/glide-data-grid/dist/js/data-grid/data-grid-lib.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 /home/fraps/Coding/looselyhub/looselyhub/node_modules/direction/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 Object.<anonymous> (/home/fraps/Coding/looselyhub/looselyhub/node_modules/@glideapps/glide-data-grid/dist/js/data-grid/data-grid-lib.js:19:41)
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)
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 Object.<anonymous> (/home/fraps/Coding/looselyhub/looselyhub/node_modules/@glideapps/glide-data-grid/dist/js/data-editor/data-editor.js:22:20)
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) {
code: 'ERR_REQUIRE_ESM'
}
How I’m importing:
import DataEditor from '@glideapps/glide-data-grid'
import { DataEditorContainer, GridColumn, GridCell } from '@glideapps/glide-data-grid';
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
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 >Must use import to load ES Module · Issue #28 · sindresorhus ...
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/salty/Documents/src/youtu-bu/node_modules/ky-universal/index.js require() ...
Read more >Error [ERR_REQUIRE_ESM]: How to use es6 modules in ...
All you have to do is adding the flag --experimental-modules that supports the new es6 import/export statement also the order is important ...
Read more >Error ERR REQUIRE ESM | Must use import to load ES Module
JS - JavaScript. Error ERR REQUIRE ESM | Must use import to load ES Module. 15K views 1 year ago. Sagar S. Sagar...
Read more >Must use import to load ES Module - Netlify Support Forums
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /var/task/node_modules/@steeze-ui/heroicons/index.js require() of ES modules is ...
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 FreeTop 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
Top GitHub Comments
I had the same issue. The latest version of direction is 2.0.0, which seems generate the same error above.
When I downgraded to direction@1.0.4 as @itchii-06 commented, everything worked as expected.
The README has been updated with
direction@1