Npm allows you to use multiple versions of the same package in a project. This is a powerful feature.
However, in most front-end projects, I would say that it is undesirable to have dependencies on the same library in different versions.
The presence of dependencies on the same library in different versions means that the end user will have to download this library several times (as separate requests or as part of a larger package).
However, if npm is used to manage dependencies of the frontend project, you can very quickly finish working with dependencies on the same library in different versions.
I think that in most cases this is undesirable, and most of the time we are not even aware of the situation.
A simple case when we find ourselves in this situation:
At some point in time you set react-router, and historyin the project:
npm i -S react-router@1.0.0-rc1
npm i -S history@1.17.0
At this time, react-routeris dependent on history@1.17.0. As a result, your project as a whole has only a dependency on this version history.
Later you decide to upgrade to the latest version react-router:
npm i -S react-router@2
Now react-routerhas a dependency on history@2.
As a result, your project now has a dependency on history@1.17.0and a transitive dependency on history@2.
Both versions historyare included in yours npm_modules.
If you use a set of modules, such as Webpack or Browerify, you get a package containing both versions history.
, . , , `history @2.
?
, ?
, , ?
, npm/Webpack/Browserify , . , , .
: https://github.com/jbandi/npm-package-problems