2021年2月9日星期二

Why is there a difference between the node_modules folder of a project installed locally vs globally?

Let's say I have a project with a dependency, A.

A has its own dependency on B.

If I npm install A into my project, my node_modules folder looks like the following. Note that B has been installed as a top level module:

/myproject      /node_modules          /A          /B  

Then if I were to depend on myproject from anotherproject, my node_modules folder looks like this:

/anotherproject      /node_modules          /myproject          /A          /B  

But, if I were to install myproject as a global module npm install -g myproject, the node_modules folder ends up looking like this (no top-level B):

/myproject      /node_modules          /A  

Why is this?

(npm 6.14.4}

https://stackoverflow.com/questions/66130737/why-is-there-a-difference-between-the-node-modules-folder-of-a-project-installed February 10, 2021 at 12:00PM

没有评论:

发表评论