[Enhancement]: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
See original GitHub issuesystem: macOS node version: 14.2 webpack@4.43.0 webpack-cli@3.3.11
So, i have config file “webpack.config.js”
export default { entry: './i.js', output: { filename: 'bundle.js' } }
in package.json i have “type”: “module”
in i.js i have code
import * as path from 'path';
console.log(path);
so i use cmd
webpack --config webpack.config.js
and got error:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/x8core/Projects/anyx-cli/webpack.config.js
require() of ES modules is not supported.
In documentation i see. “When using webpack to bundle your application, you can pick from a variety of module syntax styles including ES6”
Why i am getting such error? Am i need to use babel?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:18
- Comments:28 (9 by maintainers)
Top Results From Across the Web
Must use import to load ES Module - javascript - Stack Overflow
json file I still am getting an error. Trying to decipher the error, I wonder if the problem is that svg2img is not...
Read more >Error [ERR_REQUIRE_ESM]: Must use import to load ES ...
It seems indeed an issue with that module. I have created the node.js program from the readme: bash-5.0$ cat /data/test.js var md =...
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 ... Error [ERR_REQUIRE_ESM]: Must use import to load...
Read more >ECMAScript modules | Node.js v19.3.0 Documentation
startup/index.js' ) must also be fully specified. This behavior matches how import ... Instead, use import() to load an ES module from a...
Read more >ostiahailo - Sonar Community - SonarSource
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ... ERROR: internal/modules/cjs/loader.js:1174 ERROR: throw new ...
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 absolutely madness
Because you can’t use
import
insidecjs
, please read how it works