"Must use import to load ES Module" problem
See original GitHub issueWith node 12 , when I tries the sample I got the following error. It looks like it cannot import the module. Does it support node 12?
$> node -r esm
Welcome to Node.js v12.16.1.
> import LatLon from 'geodesy/latlon-spherical.js';
.../node_modules/geodesy/latlon-spherical.js:1
Uncaught:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: .../node_modules/geodesy/latlon-spherical.js
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1174:13) {
code: 'ERR_REQUIRE_ESM'
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Importing in Node.js: error "Must use import to load ES Module"
The problem is that Node.js does not currently support import and export natively yet. It is still experimental according ...
Read more >Error: Must use import to load ES Module · Issue #1956 - GitHub
After update GOT library to version 12.0.0 I've got an error: Error: Must use import to load ES Module: .
Read more >Must use import to load ES Module - Help - Pipedream
Hi, suddenly my workflow started to fail with the following error: “Must use import to load ES Module”. I know there's a similar...
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 >Must use import to load ES Module - Auth0 Community
JS. When I follow the error instructions and use import I get “Cannot use import statement outside a module”. So I fell back...
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 get the same error with node
v15.3.0
and with the recommended flags enabled.Hi,
I got the same error message when trying to use V2 on CommonJs modules. Thus, I migrated to using v2 with some code changes as examples below. Basically, in recent Node versions > v12.x, you can use dynamic module loading directly. Note that dynamic ES modules loading works asynchronously.