Error: Must use import to load ES Module
See original GitHub issueWhat version of Next.js are you using?
10.2.2
What version of Node.js are you using?
14.16.1
What browser are you using?
Edge
What operating system are you using?
Windows
How are you deploying your application?
local development
Describe the Bug
When importing the react-konva
package I get this error
Server Error
Error: Must use import to load ES Module: C:\Users\bucsa\dev\atomic\node_modules\konva\lib\Core.js
require() of ES modules is not supported.
require() of C:\Users\bucsa\dev\atomic\node_modules\konva\lib\Core.js from C:\Users\bucsa\dev\atomic\node_modules\react-konva\lib\ReactKonvaCore.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 Core.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\bucsa\dev\atomic\node_modules\konva\package.json.
The same error was thrown when I tried to import the chessops
library but managed to work around that by dynamically importing it when the component loads. Neither that nor importing with next/dynamic
could solve the issue with this package though.
Expected Behavior
I expected the components to be imported and not throw an error.
To Reproduce
Install react-konva
and konva
import { Stage } from 'react-konva'
const Example = () => {
return <Stage></Stage>
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:15
- Comments:28 (5 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 [ERR_REQUIRE_ESM]: Must use import to load ES ...
I just installed the library onto my TypeScript project and I get the following error: Error [ERR_REQUIRE_ESM]: Must use import to load ES ......
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”. @germanescobar you can give this...
Read more >Must use import to load ES Module - Netlify Support Forums
Hello, I have been getting this error on production, but it works fine in my local when I try to preview using netlify...
Read more >path/node_modules/dot-prop/index.js` and I do not want to ...
Error: [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/node_modules/dot-prop/index.js require() of ES modules is not supported.
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 actually happens intermittently with ReactMarkdown.
Same issue, any updates?