question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v5] export 'default' (imported as 'echarts') was not found in 'echarts'

See original GitHub issue

Version

v5

Steps to reproduce

<template>
  <div id="main" style="width: 600px; height: 400px"></div>
</template>

<script>
import echarts from 'echarts'

export default {
  mounted() {
    // based on prepared DOM, initialize echarts instance
    const myChart = echarts.init(document.getElementById('main'))

    // specify chart configuration item and data
    const option = {
      title: {
        text: 'ECharts entry example',
      },
      tooltip: {},
      legend: {
        data: ['Sales'],
      },
      xAxis: {
        data: ['shirt', 'cardign', 'chiffon shirt', 'pants', 'heels', 'socks'],
      },
      yAxis: {},
      series: [
        {
          name: 'Sales',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20],
        },
      ],
    }

    // use configuration item and data specified to show chart
    myChart.setOption(option)
  },
}
</script>

<style lang="scss" scoped></style>

What is expected?

Works out of the box

What is actually happening?

Not working


Works in v4 though, how to import echarts ESM in v5?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
pissangcommented, Dec 3, 2020

import echarts from 'echarts' is not a recommanded usage for es modules and is deprecated in 5.0

Use import * as echarts from 'echarts' instead

1reaction
susiwen8commented, Dec 4, 2020

@wenfangdu Maybe this article can give you an answer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

echarts安装后报错“export 'default' (imported as ... - CSDN博客
echarts 安装后报错“export 'default' (imported as 'echarts') was not found in 'echarts' · 2.解决办法一 · 解决办法二.
Read more >
Migration from v4 to v5 - What's New - Basics - Apache ECharts
Importing ECharts. Removing Support for Default Exports. Since v5 , echarts only provides named exports . So if you are importing echarts like...
Read more >
Echarts报“export 'default' (imported as 'echarts') was ... - 博客园
一、问题分析找不到导入的Echarts,原因是因为echarts for react不支持5.0版本以上的echarts 二、解决方案1.查看自己echarts的版本在文件package.jso.
Read more >
Echarts报“export 'default' (imported as 'echarts ... - CodeAntenna
Vue的main.js中引入echarts后报"export'default'(importedas'echarts')wasnotfoundin'echarts'解决办法:1、5.0以下的版本跟5.0以上的版本引入方法不一样5.0以上可以通过: ...
Read more >
Import ECharts - Basics - The Apache Software Foundation!
There are two approaches to using ECharts as a package. The simplest approach is to make all functionality immediately available by importing from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found