ERROR in ./~/react-chartjs-2/lib/index.js
Module not found: Error: Can't resolve 'chart.js' in 'node_modules/react-chartjs-2/lib'
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
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
Most helpful comment
chart.js is a peer dependancy. make sure you include a version in your package.json yourself