Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 5 tasks
Jfs007 opened this issue Mar 30, 2018 · 40 comments
Closed
2 of 5 tasks

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

Jfs007 opened this issue Mar 30, 2018 · 40 comments

Comments

@Jfs007
Copy link

Jfs007 commented Mar 30, 2018

The type of this issue / Issue 类型

  • Feature request / 新特性需求
  • Bug report / Bug 报告

Not introduced by ECharts / 非 ECharts 本身问题

Problems about ECharts itself are not handled in this repo. / 本 repo 不负责处理 ECharts 本身的问题。

  • I've checked it's not a problem of ECharts itself. / 我已检查过,这个问题非 ECharts 本身的问题。

Details / 详情

How are you importing Vue-ECharts? / 你是如何引入 Vue-ECharts 的?

  • Bundled version/打包版本 (import ECharts from 'vue-echarts')
  • The .vue component/.vue 组件 (import ECharts from 'vue-echarts/components/ECharts')

The version of Vue-ECharts you are using / Vue-ECharts 的版本

Reproduction link / 复现链接

For bug reports, please provide the steps to reproduce and if possible a minimal demo of the problem. Please paste the link to your CodeSandbox demo below:

对于 Bug 报告,请在下面提供复现的步骤,最好是最小化的能够重现问题的 demo。请在下方贴入在 CodeSandbox 上 demo 的链接:

@Jfs007
Copy link
Author

Jfs007 commented Mar 30, 2018

image

@Jfs007
Copy link
Author

Jfs007 commented Mar 30, 2018

我检查这个问题说是webpack2不能再同时使用import和moudle.exports但是我看了下这个组件Echarts.vue并没有这个问题

@Justineo
Copy link
Member

你提供的信息和代码都不够完整,无法重现就无法定位问题。

@Jfs007
Copy link
Author

Jfs007 commented Mar 30, 2018

直接在vuecli里面引入这个echarts组件,没有做其他处理,,报的错误就是Cannot assign to read only property 'exports' of object '#'

@Justineo
Copy link
Member

需要可重现的步骤。vue cli 用的什么版本,什么模板,怎么引入的,啥都没有啊。

@Jfs007
Copy link
Author

Jfs007 commented Mar 30, 2018

抱歉,
image
在mainjs载入
image另外 我在base.conf.js假如了要求的vueecharts和resize-detector ,,

image

我的pacckjson依赖是如此的
"dependencies": {
"echarts": "^4.0.4",
"echarts-gl": "^1.1.0",
"element-ui": "^2.2.1",
"resize-detector": "^0.1.5",
"tween": "^0.9.0",
"vue": "^2.5.2",
"vue-echarts": "^3.0.5",
"vue-router": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0",
"pug": "^2.0.0-rc.4",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},

@Jfs007
Copy link
Author

Jfs007 commented Mar 30, 2018

额我把
image
这个包含对的东西移除掉没有报那个问题了

@Justineo
Copy link
Member

这样你的代码就不会过了babel-loader 了。

@Jfs007
Copy link
Author

Jfs007 commented Mar 30, 2018

加上去报错的问题不知道怎么导致的

@Jfs007
Copy link
Author

Jfs007 commented Mar 30, 2018

请问下我该如何去添加echartsgl呢,我现在修改了你的源码让他能够加载

image

@Jfs007 Jfs007 closed this as completed Mar 31, 2018
@Jfs007 Jfs007 reopened this Mar 31, 2018
@Justineo
Copy link
Member

Justineo commented Apr 1, 2018

按你所说的步骤无法复现你的问题。你可以建一个 repo,构建一个可以复现的环境再来 reopen 吧。

PS. 建议以后在任何地方提 issue 都不要截图,请多为别人做一些考虑。

@Justineo Justineo closed this as completed Apr 1, 2018
@Oscar-ren
Copy link

最新版仍有这个问题,在某些机器情况下出现(我这儿有个同事的windows出现这个错误),目前我直接编译源代码不会报错,应该是rollup编译的过程中某个参数导致的,还在探索中......

@Justineo
Copy link
Member

Justineo commented Apr 12, 2018

@Oscar-ren webpack/webpack#4039 是否是这个问题?

@Oscar-ren
Copy link

嗯,我在参考这个,但还没找到问题所在

@gagaboy
Copy link

gagaboy commented Jun 20, 2018

将babelrc中的modules: false去掉应该就可以了

@io-o
Copy link

io-o commented Jul 23, 2018

image
将babelrc中的plugins清空不会报错了。

@shannonliang312
Copy link

这个问题现在仍然存在,根据上面兄弟给出的解决办法:
1、去掉webpack.base.conf.js文件中

include: [
          resolve('src'), 
          resolve('test'), resolve('node_modules/webpack-dev-server/client'),
      -   resolve('node_modules/vue-echarts'),
      -   resolve('node_modules/resize-detector')
        ]

后两行
2、.babelrc中,去掉

 "plugins": [
        "transform-vue-jsx", 
     -  "transform-runtime"
]

否则会一直报这个错误...还请大神给看看

@Justineo
Copy link
Member

Justineo commented Aug 3, 2018

去掉以后不会转译,只能在最新版浏览器 Chrome 里用,如果你能接受的话自然也是可以的……

webpack/webpack#4039 (comment) 这个 comment 看过了吗?

@shannonliang312
Copy link

shannonliang312 commented Aug 6, 2018

您好:
这个comment看过了,但是不知道怎么修改....报错的地方是lodash包里,用了module.exports,transform-runtime自动加上了import导致报错?不太确定是不是这个原因...
还有一个问题,就是babel-loader的include里面不是已经有了src目录了嘛?引用vue-charts的代码都在src里面,这样也不能转译吗?
谢谢

@lynzz
Copy link

lynzz commented Sep 21, 2018

@Justineo 我建了一个 repo, https://github.com/lynzz/vue-echart4-demo, 可重现此问题

@hiwanz
Copy link

hiwanz commented Sep 21, 2018

旧项目升级需要以下操作后,重新build:
rm package-lock.json
rm -rf node_modules
npm i

@lynzz
Copy link

lynzz commented Sep 21, 2018

@hiwanz 可以了

@gabengcuiyeye
Copy link

去掉了"plugins": [
- "transform-runtime"
]就可以了。。。

@Nosnickers
Copy link

Nosnickers commented Jan 11, 2019

我的项目也这么报错,最后发现自己装的echarts版本和vue-echarts引用的echarts版本不一致导致的。
换成同一个版本解决问题!!

@skywalkers2012
Copy link

请问这个问题最终是怎么解决的?

@skywalkers2012
Copy link

@hiwanz 可以了

请问是怎么解决的

@hiwanz
Copy link

hiwanz commented Jan 14, 2019

@hiwanz 可以了

请问是怎么解决的

@skywalkers2012 你往上看一楼

@Justineo
Copy link
Member

Justineo commented Jan 22, 2019

楼上各位,如果问题是由于引入多个不同版本的 echarts 导致的问题,可以考虑升级到最新版本 4.0.1。更新以后 vue-echarts 不再自行安装 echarts,用户需要手动在项目中引入 echarts 依赖,这样就不再会有重复引入不同 echarts 的问题了。

当然,更新到 4.x 的话记得 check 一下 CHANGELOG

@conanliuhuan
Copy link

遇到相同的问题,根据上面的描述,分别安装了最新版本的vue-echarts和echarts,问题仍然存在。
目前凑合的解决方法是:移除vue-echarts和echarts,仅安装@3.1.3版的vue-echarts

@liwenda122

This comment has been minimized.

@shannonliang312
Copy link

@liwenda122 兄dei你这话说的太重了....开源项目免费给你用,用问题很正常,说出来大家讨论解决就好,没必要说这话......也没看出来这个issue有谁在教育别人.....

@liwenda122

This comment has been minimized.

@Justineo
Copy link
Member

Justineo commented Jul 12, 2019

这是一个已经解决的问题。升级到 v4 的一大原因就是要解决这个问题,如果你眼睛不好使我可以带你坐电梯:点我 ↑

既然当了维护者就要有解决问题的态度

请不要给别人设置义务,你没有这个权利,谢谢。

当然,你有权不接受教育,我也有权不再为你提供支持。不过污染环境的话就走好不送了。

@liwenda122

This comment has been minimized.

@leotengfei
Copy link

@Justineo 经过测试,最新版本的v4.0.3依然存在这个问题。按照提供的方法无法解决,目前只能采用v3.0.3 conanliuhuan这位老兄提供的解决方法,亲测可用!

@HydrogenPan19
Copy link

4.0.3 修改 babel 可以使用

// babel.config.js
module.exports = {
  presets: [
    '@vue/app',
  ],
  sourceType: 'unambiguous', // 添加这行
}

@leotengfei
Copy link

4.0.3 修改 babel 可以使用

// babel.config.js
module.exports = {
  presets: [
    '@vue/app',
  ],
  sourceType: 'unambiguous', // 添加这行
}

你这个是vue-cli 3.0的 vue-cli 2.0怎么配置有没有什么建议

@Justineo
Copy link
Member

Justineo commented Sep 6, 2019

如果仍然有问题,请提供最小化的复现(可以新建一个 repo),不然我们无法提供帮助。

@HydrogenPan19
Copy link

HydrogenPan19 commented Sep 7, 2019

@Justineo 确定是 babel 版本问题。
本来想用 vue cli 3 创建一个重现,却发现没有问题。
对比了 yarn.lock ,有问题项目 @vue/cli-plugin-babel@babel/core 依赖锁定在 7.4.4

将 babel 从 7.4.4 升到 7.6.0 后,无须 加 sourceType: 'unambiguous' 也正常了


补充:
本想创建 @babel/core 7.4.4 重现 repo 的。但打包出来没有问题,但我再次确认过了,在旧项目里面升级 @babel/core 依赖的确解决了。不确定具体原因。

@zjlovezj
Copy link

zjlovezj commented Sep 9, 2019

我用的 [email protected][email protected]

把 vue.config.js 的配置修改成这样可以正常运行。

// 旧配置
  transpileDependencies: [
    /\bvue-echarts\b/,
    /\bresize-detector\b/
  ]
// 新配置
  transpileDependencies: [
    /\bvue-echarts\/components\b/
    /\bresize-detector\b/
  ]

外层要有 lodash 的依赖~ 一般项目都有,没有的话,就自行添加这个依赖。

PS,其他项目比如 vuepress 也有类似问题,刚解决。看作者是否能从根源解决这个问题,谢谢~
vuejs/vuepress#1807 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests