Martin Carp
Martin Carp

Reputation: 55

Why every time I install a package with npm or yarn it installs all the dependencies?

every time I install a dependency, for example yarn add socketio, instead of installing that dependency alone it installs all the ones from the package.json. Is there a way that I only install the dependency that I indicate and not all?

Upvotes: 0

Views: 1463

Answers (1)

Viral Patel
Viral Patel

Reputation: 1156

Checked with v1.22.0.

This should only happen if you have a package.json file and its dependencies are not installed.

Consider the example, where you have underscore as dependency in package.json and somehow it is not installed yet. Now, you're trying to install let's say color package. In this case, yarn will install color as well as underscore as dependencies. But, once all the dependencies mentioned in package.json are installed, yarn will not install dependencies again.

Upvotes: 2

Related Questions