Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The requested module '/node_modules/.vite/deps/chart_js.js?v=425f86ec' does not provide an export named 'default'

I’m using Sveltekit and I upgraded chart.js from @2.9.4 to its latest version, upon upgrading I get the below error:

500
The requested module '/node_modules/.vite/deps/chart_js.js?v=425f86ec' does not provide an export named 'default'
SyntaxError: The requested module '/node_modules/.vite/deps/chart_js.js?v=425f86ec' does not provide an export named 'default'

I get above stated error as I import it as below:

import chartjs from 'chart.js';

I also get the same error in any version above chart.js@2.9.4.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank You.

>Solution :

Chart.js V3 is treeshakable so you need to import and register everything or if you want everything you need to import the chart from the auto import like so:

import Chart from 'chart.js/auto';

For more information about the different ways of importing and using chart.js you can read the integration page in the docs.

Since you are upgrading from Chart.js V2 you might also want to read the migration guide since there are some major breaking changes between V2 and V3

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading