Cannot assign to read only property 'exports' of object '#<Object>'

运行一下以前的一个Vue+webpack的 vue仿新闻网站  小项目,报错

由于自己vue学习不深入,老是这个报错,找了好久(确切的说是整整一下午^...^)才找到原因 -v-

Uncaught TypeError: Cannot assign to read only property ‘exports‘ of object ‘#<Object>‘

点开错误的文件,标注错误的地方是这样的一段代码:

import {normalTime} from ‘./timeFormat‘;

module.exports={
  normalTime
};

就是module.exports;

解决方法

同过谷歌查找,和论坛各种搜索:

原因如下:The code above is ok. You can mix require and export. You can‘t mix import and module.exports.

翻译过来就是说,代码没毛病,在webpack打包的时候,可以在js文件中混用require和export。但是不能混用import 以及module.exports 

因为webpack 2中不允许混用import和module.exports ,

解决办法就是统一改成ES6的方式编写即可.

import {normalTime} from ‘./timeFormat‘;

export default normalTime;

再次运行:

Cannot assign to read only property 'exports' of object '#<Object>'

时间: 2024-08-01 20:39:26

Cannot assign to read only property 'exports' of object '#<Object>'的相关文章

webpack报错:Cannot assign to read only property &#39;exports&#39; of object &#39;#&lt;Object&gt;&#39;

这个倒霉错误在mac电脑上开发的时候非常顺利,可是用windows的时候就会报错. 百度查不到,google一查果然有. 原因是:The code above is ok. You can mix require and export. You can't mix import and module.exports. 也就是说,在webpack打包的时候,可以在js文件中混用require和export.但是不能混用import 以及module.exports. 于是查了一下代码,在自己的ma

Vue的报错:Uncaught TypeError: Cannot assign to read only property &#39;exports&#39; of object &#39;#&lt;Object&gt;&#39;

Vue的报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' 1.运行一下以前的一个Vue+webpack的 vue仿新闻网站  小项目,报错 由于自己vue学习不深入,老是这个报错,找了好久(确切的说是整整一下午^...^)才找到原因 -v- Uncaught TypeError: Cannot assign to read only property 'expor

vue-cli3 打包时使用‘babel-loader’遇到Cannot assign to read only property ‘exports’ of object &#39;#&#39;问题的解决方法。

原文链接:http://www.pianshen.com/article/9677274805/ 第一种原因就是import和module.exports的混用要知道commonJS和ES6的语法是不太一样的前者是require和module.exports后者则是import和exports,当你混用这两个语法的时候,webpack就会报错,也就是第一种情况.为了使编译好的程序能在大多数浏览器下运行.webpack里面有一个编译器叫Babel,负责把ES6的语言转化为commonJS以兼容绝大

vue 项目启动报错:Cannot assign to read only property &#39;exports&#39; of object &#39;#&lt;Object&gt;&#39;

最近做项目,打开一个新项目,在启动时报错 查询百度结果是 在webpack打包的时候,可以在js文件中混用require和export.但是不能混用import 以及module.exports. 因为webpack 2中不允许混用import和module.exports, 但是在经过我试验之后,发现不起作用,再去百度,发现一个解决办法: 执行npm: npm install babel-plugin-transform-es2015-modules-commonjs 然后在 babelrc文

Vue报错:Uncaught TypeError: Cannot assign to read only property &#39;exports&#39; of object 的解决方法

问题是这样的:如下>> 解决办法: 1“:我的webpack 最高版本,造成 混用import和module.exports :所以降低webpack版本 安装指定版本:npm install [email protected] -g 例如:npm install [email protected] -g 删除 编译目录文件: 2重新生成 然后输入启动命令: 成功解决!效果: 方法二: 注释掉后一个 重新生成,启动项目 OK! Vue报错:Uncaught TypeError: Cannot

Cannot assign to read only property &#39;exports&#39; 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

关于vue-cli3打包时遇到Cannot assign to read only property &#39;exports&#39; of object &#39;#&lt;Object&gt;&#39;问题的解决方法。

vue-cli3打包时遇到Cannot assign to read only property 'exports' of object '#<Object>'问题的解决方法. 大致是说,在webpack打包的时候,可以在js文件中混用require和export.但是不能混用import 以及module.exports. 因为webpack 2中不允许混用import和module.exports,   为了使编译好的程序能在大多数浏览器下运行.webpack里面有一个编译器叫Babel,

Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#&lt;Object&gt;‘的解决方法

因为webpack 2中不允许混用import和module.exports , 解决办法就是统一改成ES6的方式编写即可. import { copyDeep } from '@/libs/tools.js'; export default copyDeep; 原文地址:https://www.cnblogs.com/easonw/p/10595576.html

Adding property to a json object in C#

Adding property to a json object in C# you can do it with a dynamic object dynamic obj = JsonConvert.DeserializeObject<ExpandoObject>(jsonString); obj.Values.valueName4 = "value4"; System.Console.WriteLine(JsonConvert.SerializeObject(obj))