Can someone please explain npm dependencies?

Viewed 83

I am not a newbie, but I am still confused with the way npm puts packages in node_modules.

So, what I can see is:

  1. My project's dependencies are installed into node_modules. That's as expected.
  2. Some other packages are installed into the project's node_modules as well, even if those packages are not within my project's dependencies or devDependencies. Okay, I assume that these are dependencies of my project's dependencies and hence, npm throws just every package to the project's node_modules.
  3. Now the most obscure part. Of those packages (from paragraph 2 above), some contain their own node_modules and packages inside it, but others do not contain node_modules and store their dependencies in the project's node_modules! The heck?

Why is that inconsistent behavior, why some sub-dependencies have their own node_modules and other sub-dependencies just drop their deps in the project's node_modules?

0 Answers
Related