Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: 581
See original GitHub issueBug Report
Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: 581
Current behavior
Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: 581
Expected behavior There is no abnormal
Environment
webpack version: “webpack”: “^5.13.0”, Node.js version: v10.15.3 Operating System: mac Additional tools:vscode “@babel/core”: “^7.12.10”, “@babel/preset-env”: “^7.12.11”,
Possible Solution
Additional context babel.config.js:
module.exports = {
presets: [
[
'@babel/preset-env',
{
corejs: 2,
useBuiltIns: 'usage'
}
],
'@vue/babel-preset-jsx'
],
plugins: []
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ES Modules may not assign module.exports or exports.*, Use ...
I get this error when I try to export a function with module.exports and when I import it inside another file. I tried...
Read more >module.exports and ES modules (ESM) import export in Node.js
The syntax would change a little bit as we cannot assign object and access its elements as we would do directly with module.exports,...
Read more >Error when trying to implement laravel translation into vuejs file
Error : ES Modules may not assign module.exports or exports ; export syntax, instead: ./resources/app/translation.js at Object ; as exports] (app.js:417882) ...
Read more >Changelog - esbuild - Breword 文档集合
esm -file.js var esm_file_exports = {}; __export(esm_file_exports, ... syntax and uses browser-style import order that other languages might not be expecting ...
Read more >import - JavaScript - MDN Web Docs - Mozilla
To load modules in non-module contexts, use the dynamic import syntax ... exporting it may mutate it and the imported value would change....
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
@Mikilll94 Adding
sourceType: "unambiguous"tobabel.config.jsseems to fix the error."umabiguous"tells Babel to automatically detect if it’s transforming a CJS or ESM file, so that it doesn’t injectimportstatements in CJS dependencies.Then there is another error (
process is not defined), but it seems unrelated.Adding
"sourceType": "unambiguous"to my babel.config.json fixed the issueThank you so much!