简体   繁体   English

npm(或纱线)如何处理我的依赖关系?

[英]How does npm (or yarn) handle dependencies of my dependency?

I've been using npm and yarn for a while, and still have some questions on dependency graph.我一直在使用 npm 和 yarn 有一段时间了,仍然对依赖图有一些疑问。

If i install two packages, A and B of certain version, and if B has A as dependency, but of a different version from my direct dependency, does both versions get installed?如果我安装了两个包,某个版本的 A 和 B,并且如果 B 具有 A 作为依赖项,但与我的直接依赖项的版本不同,是否安装了两个版本?

For example, my package.json has package A of version 1.0.0 as dependency, but package B has dependencty A of version 0.9. For example, my package.json has package A of version 1.0.0 as dependency, but package B has dependencty A of version 0.9. I wonder if both versions are installed, and if so, where我想知道是否安装了两个版本,如果是,在哪里

If not so, how is this situation handled?如果不是这样,这种情况如何处理?

Yes.是的。 Each dependency you install have a packages.json and a node_modules folder in it.您安装的每个依赖项都有一个packages.json和一个node_modules文件夹。 The inner node modules will contain it's dependencies.内部节点模块将包含它的依赖项。

Here's a screenshot of body_parser这是body_parser的截图

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM