Node js adding unwanted modules when I do npm install [duplicate]

拜拜、爱过 提交于 2019-12-23 19:13:56

问题


I am trying to spin up a node service on my mac. When I run npm install in the folder where my node service is, it is installing modules which are not mentioned in my package.json. There are extra modules which I am not expecting and some modules that I expect are missing. What could be the reason? How does the node modules folder get created. Does it use any global set up? I am a newbie to nodejs and any help will be appreciated.


回答1:


Well, it has been introduced with npm3 (https://github.com/npm/npm/blob/master/CHANGELOG.md#v300-2015-06-25):

Flat, flat, flat!

Your dependencies will now be installed maximally flat. Insofar as is possible, all of your dependencies, and their dependencies, and THEIR dependencies will be installed in your project's node_modules folder with no nesting. You'll only see modules nested underneath one another when two (or more) modules have conflicting dependencies.




回答2:


I believe this is something new that happened in the newest version of npm.

If I'm not mistaken, it's installing all the dependencies flat instead of nested inside of whichever module that needs it.



来源:https://stackoverflow.com/questions/33520581/node-js-adding-unwanted-modules-when-i-do-npm-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!