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-2026 CODEPRJ.COM