Topic: React in both dependancy & peerDependancy, multiple react version errors
mpcooke4 pro asked 3 years ago
This may be related to my own misunderstanding of how npm packages work but I'm a bit confused. I am including mdbreact using the git URL for the pro version (git.mdbootstrap.com/mdb/react/re-pro.git) in my package.json.
Previously I had the react package I wanted installed specified in my package.json too, upon a recently npm update react started complaining about multiple versions of react. I am not sure why because mdbreact and my package.json specific 17.0.1.
I temporarily have it working again by not specifying react in my own package.json although of course there is a complaint by npm that I have the missing peer dependancy react that is required mdbreact.
I think my questions are: Is it intended that mdbreact manages the react version or that I specify it in my own package.json? Does it make sense to have a package specified in mdbreacts dependancy's and peerDependencies in the mdbreact package.json? (especially given that react hates having multiple versions installed)
Matt.
Krzysztof Wilk staff answered 3 years ago
Hi!
You can try to place react in both peerDependencies and devDependencies. Placing it in dependencies (without peer or dev) will cause multiple versions of React to be installed.
Command npm dedupe
can also be helpful - it removes recursively unnecessary copies of dependencies (including React) :)
Keep coding,
Krzysztof Wilk
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: 5.0.1
- Device: macbook
- Browser: chrome
- OS: mac os
- Provided sample code: No
- Provided link: No