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 '#' 问题 Cannot assign to read only property 'exports' of object '#' Cannot assign to read only property 'exports' of object '#' Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#‘的解决方法 Vue报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object 的解决方法 关于vue-cli3打包时遇到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 '#' Cannot assign to read only property 'exports' of object '#' ,文件名大小写问题!!!
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM