[Chartjs]-Uncaught ReferenceError : require is not defined – Chart.js

46πŸ‘

βœ…

in your code, pull the bundle instead. E.g ~/Plugin/Chart.js/dist/Chart.bundle.js

6πŸ‘

3πŸ‘

For the Angular CLI users -> No need to add this script in angular-cli.json file, because angular-cli should pack ng2-charts lib(and other from node_modules) and add it automatically to your index.html.

https://github.com/valor-software/ng2-charts/issues/832

0πŸ‘

First include the require.js file then use RequireJS. You can download here.

0πŸ‘

I had the same problem after installing with Bower.

The solution as proposed in https://github.com/jtblin/angular-chart.js/issues/466 was to get specific versions of chart.js and angular-chart.js (tested with angular 1.4.0)

If you use Bower, try this in your bower.json

"chart.js": "npm:chart.js#2.1.0",
"angular-chart.js": "1.0.1"

and then run: bower install


If npm:chart.js is not working for you, you need to use a resolver.

1- Add to your .bowerrc:

{
  "resolvers": [
    "bower-npm-resolver"
  ]
}

2- Install bower-npm-resolver

npm install -g bower-npm-resolver

3- Now run bower install again

Leave a comment