I want to install Chart.js in my Laravel projects. Using npm install, a config for Webpack, and seeing my index page with some Chart.js examples. On my first try, I got this error in the browser. Maybe I'm not configuring the webpack correctly?
Uncaught ReferenceError: Chart is not defined at (index):134
So I copied and pasted this require that I found on Chart.js doc integration.
require(['path/to/chartjs/dist/Chart.min.js'], function(Chart){
var myChart = new Chart(ctx, {...});
});
I got this error on npm run dev
.
ERROR in ./resources/js/app.js Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: /home/sa/laravelproject/resources/js/app.js: Unexpected token (37:37)
35 | 36 | require(['path/to/chartjs/dist/Chart.min.js'], function(Chart){
37 | var myChart = new Chart(ctx, {...}); | ^ 38 | });