简体   繁体   中英

Should I install npm packages that are dependencies of other installed packages?

If I install a npm package foo that has a dependency bar , then I can just use bar in my code. Is there a good reason to still do a npm install bar ? Eg when the maintainer of foo decides to replace bar with something new? Or is that seen as a breaking change in which case I might have to adjust my code anyway?

If to use "bar" you are doing npm i "foo" then it means you are directly depending on "foo" instead of "bar", it simply does not make sense anywhere. There are reasons such as,

  1. You may be missing out some features in the "bar" package which is not used in "foo"
  2. Any error and lag in the "foo" package can directly affect you even when you are not using any of its part
  3. Last but not least the one you stated is also 100% correct

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