I am now trying to figure out why it is necessary to specify all the dependencies explicitly in the packages.json file.
For example: I want to use the react-router library. The official documentation says:
npm install react-router@6 react-router-dom@6
This means that to work with this library, I need to install (and maintain/update) two packages. Of course, there is no problem updating two packages, but when there are many such packages, it looks strange.
Also, the official documentation says:
you should never import anything directly from the react-router package, but you should have everything you need in either react-router-dom
I'm trying to figure it out further and I look at how the packages.json file works for the react-router-dom library and i see
"dependencies": {
"react-router": "6.0.0-beta.1"
},
For me, this means that if I install the react-router-dom
library, it will automatically pull up the dependencies that are specified in the dependencies
section, so react-router
should be installed automatically and I should not explicitly install it in my project.
So in general why or what benefits/best practices of install libs like
npm install react-router@6 react-router-dom@6
instead of
npm install react-router-dom@6
?