question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Import Error (Cannot Find Module)

See original GitHub issue

Would 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:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
bonbonsiregarcommented, Nov 22, 2022

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

0reactions
scottodeacommented, Nov 21, 2022

I’m also having this issue

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found