Topic: Error Can't resolve 'react-chartjs-2'
BizRTC
pro
asked 2 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 2 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:
- Remove
node_modules
folder andpackage-lock.json
file (if you havereact-chartjs-2
plugin in your dependencies in thepackage.json
file in your main project - remove it. It will be installed from our package) - Run
npm cache clean --force
to make sure that it won't install dependencies from the cache - 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 2 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 2 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 2 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 .
Wojciech Staniszewski
staff
answered 2 years ago
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 2 years ago
MDB Advanced Bundle - 1 user, Annual (MDB4-REACT-UI-KIT-Pro-Advanced-5.2.0) @
BizRTC pro commented 2 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'
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- 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