1

I'm using chart.js v4.0.1 and react-chartjs-2 v5.0.1 and when i try to import react-chartjs-2 in my js file, it shows that module is not found.

import React from "react";
import {Line} from "react-chartjs-2"

function LineChart({ chartData }) {
  return (
    <div className="chart-container">
      <h2 style={{ textAlign: "center" }}>Test Line Chart</h2>
      <Line data={chartData} width={500} height={350} />
    </div>
  );
}

export default LineChart;

I also added this line in my package.json, as per this instruction

{
  "type":"module"
}
john_smith
  • 85
  • 1
  • 9

1 Answers1

0

did you install the libraries

npm install --save chart.js react-chartjs-2

check:here

NAZIR HUSSAIN
  • 578
  • 1
  • 18