[英]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
.每次我安装依赖项时,例如
yarn add socketio
,而不是单独安装该依赖项,它会安装package.json
中的所有依赖项。 Is there a way that I only install the dependency that I indicate and not all?有没有办法只安装我指出的依赖项而不是全部?
Checked with v1.22.0
.使用
v1.22.0
检查。
This should only happen if you have a package.json
file and its dependencies are not installed.仅当您有
package.json
文件且未安装其依赖项时,才会发生这种情况。
Consider the example, where you have underscore as dependency in package.json
and somehow it is not installed yet.考虑这个例子,你在
package.json
中有下划线作为依赖项,但不知何故它还没有安装。 Now, you're trying to install let's say color package.现在,您正在尝试安装颜色package。 In this case, yarn will install color as well as underscore as dependencies.
在这种情况下,yarn 将安装颜色以及下划线作为依赖项。 But, once all the dependencies mentioned in
package.json
are installed, yarn will not install dependencies again.但是,一旦
package.json
中提到的所有依赖项都安装完毕,yarn 将不再安装依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.