Categories


Archives


Recent Posts


Categories


NPM’s Dependency Model

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

I’m coming up on about a year of full-time NodeJS work, and it’s only now that I’m starting to understand the true nature of NPM’s dependency management.

When I’ve used other systems, (primarily composer), “management” of those dependencies meant your package manager will yell as you if there’s a conflicting package.

You want to install version 3 of foo/bar? Well too bad, one of your dependencies can only deal with version 2 of foo/bar — sort it out.

NPM works a little differently. Instead of a project’s packages being one big soup, each of your dependencies will have its own node_modules folder. This means, in our scenario above, if you want version 3 of foo/bar you can have it. That other package will get its own version of foo/bar.

The article I linked above from helpful internet stranger Alexis King goes into more details about the system, including NPM’s more traditional peerDependencies.

I’m still not 100% on some of the edge cases, but at least now I understand why package conflicts have seemed like less of a thing in the past year.

Copyright © Alan Storm 1975 – 2020 All Rights Reserved

Originally Posted: 29th June 2020