node.js - npm: Where do the children dependencies come from? -
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:
- having 'peer dependencies' mean dependency need other dependencies in order function correctly.
- 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
Post a Comment