Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Error Can't resolve 'react-chartjs-2'

BizRTC pro asked 3 years ago


I downloaded the react Pro package, ran the npm install. and when I try to run the my application for the first time. I keep getting this error

./src/pages/ChartsPage.js Module not found: Can't resolve 'react-chartjs-2' in '/myapp/src/pages'

If I install the "react-chatjs-2" using npm install "react-chatjs-2

I get this error

export 'HorizontalBar' (imported as 'HorizontalBar') was not found in 'react-chartjs-2'

Help me fix this ASAP.


Krzysztof Wilk staff answered 3 years ago


Hi!

There is probably a problem with the old version of react-chartjs-2 plugin in the dependencies tree. To make it work via npm you can:

  1. Remove node_modules folder and package-lock.json file (if you have react-chartjs-2 plugin in your dependencies in the package.json file in your main project - remove it. It will be installed from our package)
  2. Run npm cache clean --force to make sure that it won't install dependencies from the cache
  3. Install your dependencies using npm install --legacy-peer-deps command

Or just use yarn and yarn command. It will also work :)

Keep coding!


BizRTC pro commented 3 years ago

@Krzysztof Wilk@Wojciech Staniszewski

That did not work either. I don't have any dependency, I just extract your package into one fresh folder and run npm install.

Still I keep getting error.


BizRTC pro commented 3 years ago

Basically, I don't even have pacakge.json file. I am just extracting your package trying use it as it is. But after running npm install . I keep getting this error. npm start

Failed to compile.

./src/pages/ChartsPage.js
Module not found: Can't resolve 'react-chartjs-2' in '/home/rajan/monsters/src/pages'


Krzysztof Wilk staff commented 3 years ago

Firstly - you have to have a package.json file after extracting our package. Without it, you couldn't install dependencies.

And as I said - you have to install dependencies with the --legacy-peer-deps flag (if you are using npm). Common npm install one won't work. So after extracting your package you have to run npm install --legacy-peer-deps. You can also use yarn instead of npm - it won't cause any problems :)


rasoul madani free commented 1 year ago

in the name the universe programmer .

thank you very much . you solved my problem . god with you .



Please try to delete the node_modules folder, clean npm cache, and run npm install again. Which version of MDB did you buy?


BizRTC pro commented 3 years ago

MDB Advanced Bundle - 1 user, Annual (MDB4-REACT-UI-KIT-Pro-Advanced-5.2.0) @


BizRTC pro commented 3 years ago

I deleted the *node_modules*

Ran npm cache clean --force Still getting this error

Failed to compile.

./src/pages/ChartsPage.jsModule not found: Can't resolve 'react-chartjs-2' in '/home/project/src/pages'


BizRTC pro answered 3 years ago


Is this the premium and priority support you guys give to your customer ?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB React
  • MDB Version: MDB4 5.0.1
  • Device: Windows
  • Browser: Chrome
  • OS: Linux
  • Provided sample code: No
  • Provided link: No