"export 'default' (Imported as 'Chart') was not found in 'Chart.js'

Asked

Viewed 514 times

0

When I give one import Chart from 'chart.js' this error appears on the terminal:

"export 'default' (imported as 'Chart') was not found in 'chart.js'

And those bugs on the console:

Error in mounted hook: "TypeError: chart_js__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor"
TypeError: chart_js__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor

I am using Vue.js 2 and the versions of Chart.js that give this error are 3.1.1 and 3.0.2, from version 2.9.4 it works normal. I tried to use the Vue-chartjs but it also makes this same import of Chart.js and ends up resulting in the same error.

1 answer

1

I’m using the most current version of Vue-chartjs launched Aug 22, 2020:

"vue-chartjs": "^3.5.1",

So all versions of Chart.Js (released after 08/2020) do not have compatibility.

Not to display/have the error in the console:

"export 'default' (imported as 'Chart') was not found in 'chart.js'

Use the version Chart.Js - 2.9.4 or any version released before 22 Aug 2020:

 "chart.js": "^2.9.4",

Browser other questions tagged

You are not signed in. Login or sign up in order to post.