[Chartjs]-Uncaught TypeError: Chart is not a constructor when using Chart.js

5πŸ‘

I think that chart.js you’re using has an error
try this one:

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script>

3πŸ‘

On Laravel mix use:

window.Chart = require('chart.js/auto').default;

1πŸ‘

Do this and it should work
import Chart from 'chart.js/auto';

https://www.chartjs.org/docs/latest/getting-started/integration.html

0πŸ‘

If you are using Chart.js v3 or higher:

import Chart from 'chart.js/auto';

If you are using Chart.js v2:

import Chart from "chart.js";

Leave a comment