React-chartjs-2: Can not resolve chart.js

Created on 18 May 2017  路  12Comments  路  Source: reactchartjs/react-chartjs-2

ERROR in ./~/react-chartjs-2/lib/index.js
Module not found: Error: Can't resolve 'chart.js' in 'node_modules/react-chartjs-2/lib'

Most helpful comment

chart.js is a peer dependancy. make sure you include a version in your package.json yourself

All 12 comments

Did you ever figure this out? I am getting the same error.

chart.js is a peer dependancy. make sure you include a version in your package.json yourself

Please add these two lines inside the angular.json file

"scripts": [
"node_modules/chart.js/dist/Chart.js",
"node_modules/hammerjs/hammer.min.js"
],

I faced same problem. How solved this?

Failed to compile.
./node_modules/react-chartjs-2/es/index.js
Module not found: Can't resolve 'chart.js'

@jerairrest If you know how to solve this. Please tell me.

Don't install chartjs like I did! Make sure to:

npm i chart.js

https://www.npmjs.com/package/chart.js?activeTab=readme

In case you're facing the issue

Failed to compile.
./node_modules/react-chartjs-2/es/index.js
Module not found: Can't resolve 'chart.js'

In React I solved this by using npm i chart.js

Apparently even though it's referred on package.json you have to install it individually

npm install --save chart.js
This worked for me.

I'm getting the same error in react and I have also done npm install --save chart.js but still not working

Don't forget that too use the library in your react project you should import it this way:
import { Pie } from "react-chartjs-2";
And not
import { Pie } from "@reactchartjs/react-chart.js"; // This import is used for the examples files only
;-)

update npm to the latest version, then install chart.js again. if still not working then clear cache from Appdata roaming.

just restart the server. that's worked for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DavidSongzw picture DavidSongzw  路  5Comments

alexchoiweb picture alexchoiweb  路  3Comments

jbbae picture jbbae  路  5Comments

justinmasse picture justinmasse  路  3Comments

RamonBeast picture RamonBeast  路  4Comments