简体   繁体   中英

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.

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?

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. The inner node modules will contain it's dependencies.

Here's a screenshot of body_parser

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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