[Bug]: Import Error (Cannot Find Module)
See original GitHub issueWould you like to work on a fix?
- Check this if you would like to implement a PR, we are more than happy to help you go through the process.
Current and expected behavior
I’m using chart.js 4.0.0 and react-chartjs-2 5.0.1 but when I try to import the module, it shows error that the module is not found.
import React from "react";
import { Chart } from 'react-chartjs-2';
import { Chart as ChartJS, LineController, LineElement, PointElement, LinearScale, Title } from 'chart.js';
ChartJS.register(LineController, LineElement, PointElement, LinearScale, Title);
function LineChart({ chartData }) {
return (
<div className="chart-container">
<h2 style={{ textAlign: "center" }}>Line Chart</h2>
<Chart
type='line'
data={chartData}
options={{
plugins: {
title: {
display: true,
text: "Test Data 2016-2020"
},
legend: {
display: false
}
}
}}
/>
</div>
);
}
export default LineChart
Reproduction
install chart.js v4.0.0 and react-chartjs-2 v5.0.1
try to import {Line} from “react-chartjs-2”; in any js files and error module not found will appear
chart.js version
v4.0.0
react-chartjs-2 version
v.5.0.1
Possible solution
No response
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Fix error: cannot find module 'x' in Node.js or 'express'
A quick fix to the error-cannot find module is to try and install all the presented module in your terminal correctly. Navigate to...
Read more >[BUG] Error: Cannot find module '#node-web-compat' #69
Describe the bug When starting my typescript application, I immediately get the error Error: Cannot find module '#node-web-compat' The stack ...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
When you get the “cannot find module” error, or “module not found”, it means you've not installed the package you're trying to use....
Read more >Error LessError: Cannot find module, because of npm install ...
I think you have use npm install outside of the project. Make sure you are on the inside of your project, then use...
Read more >Cannot find module 'X' error in Node.js | bobbyhadz
To solve the "Cannot find module" error in Node.js, make sure to install the package from the error message if it's a third-party...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems that I have to downgrade both chart.js and react-chartjs-2 to previous version, chartjs to v3.9.1 and react-chartjs-2 to 4.3.1 in order for it to work.
while using the latest version of chart.js and react-chartjs-2 require a modification in package,json, I think so. here
I’m also having this issue