node.js - npm: Where do the children dependencies come from? -


i read on github that:

grunt-mocha-test uses npm's peer dependencies functionality

i unsure "peer dependencies" checked npm docs , found:

npm awesome package manager. in particular, handles sub-dependencies well: if package depends on request version 2 , some-other-library

which take mean:

  1. having 'peer dependencies' mean dependency need other dependencies in order function correctly.
  2. npm creates tree structure, dependency root, , root dependency has children dependencies

the questions left are:

where children dependencies come from? copies? or references other dependencies present in package.json?

each of them have copy of package. example, if have project dependencies:

"dependencies": {     "node-handlebars": "*",     "less-file": "*",     "async-ls": "*",     "promise": "4.0.0" } 

and run npm install, have 4 copies of promise (the 1 declared dependency , 3 others needed each of other dependencies)

$ find . -name promise ./node_modules/async-ls/node_modules/promise ./node_modules/promise ./node_modules/node-handlebars/node_modules/promise ./node_modules/less-file/node_modules/promise 

note happen if every 1 depends on specific version of promises package (ex 4.0.0).

despite looking little redundant guess makes dependency management lot easier, , nowadays space used in general should negligible.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -