Cannot assign to read only property 'exports' of object 解決辦法


大致是說,在webpack打包的時候,可以在js文件中混用require和export。但是不能混用import 以及module.exports。

因為webpack 2中不允許混用import和module.exports,

解決辦法有兩種:

一、統一改成ES6的方式編寫即可.

二、添加插件

      npm install --save-dev @babel/plugin-transform-modules-commonjs

      在項目根目錄新增.babelrc文件,並在文件中加入

{
"plugins": ["@babel/plugin-transform-modules-commonjs"]

插件地址:https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#via-babelrc-recommended


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 解決 Cannot assign to read only property 'exports' of object '#' 問題 Vue的報錯:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' vue 項目啟動報錯:Cannot assign to read only property 'exports' of object '#' sdk uncaught third Error Cannot assign to read only property 'constructor' of object '# ' (小程序) vue項目中引入 html2canvas ,控制台報錯 Cannot assign to read only property 'className' of object '#< SVGSVGElement >' Cannot read property 'addEventListener' of null報錯的解決辦法 antd design pro of vue 'TypeError: Cannot read property 'get' of undefined'解決辦法 使用UEditor 報錯Cannot read property 'nodeType' of undefined 解決辦法 Clear Read-Only Status解決辦法(已解決)? 引用時間WdatePicker.js:Uncaught TypeError: Cannot read property 'value' of null 報錯解決辦法
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM