Comparing Package Managers – Whats the best for you?
WRITTEN BY GARETH DUNNE @DUNNEDEV
A package manager is regarded as a collection of software tools that automates the process of installing, upgrading, configuring and removing computer programs.
The concept of using a package manager is no longer new to the web development community. In fact, we are now 5 years+ into a cycle since package mangers such as NPM have been introduced.
And with that introduction they have brought with them their own quips and hazards but generally speaking they have much improved our development lives.
As well as this, the barrier to entry of someone in the community wanting to publish their own package or plugin has been significantly reduced leading to more packages being available than one could possibly comprehend learning about.
In this post, I want to compare the main package managers available to you and how they differ from each other and which one is most appropriate for the stack your using.
You might also want to check out this learning resource for all things Node.js.
Yarn is Facebook’s own published package manger and with it promises fast, reliable and secure dependency management.
It has quite a good system of caching dependencies. You might think that this seems like something that all package managers should have but its particular powerful here as its allows one to redownload packages offline.
This allows for continuous development while not having an active internet connection.
Yarn can be installed with npm and replaces npm in your terminal.
npm install --global yarn
Or on OS you can install it using brew
brew update brew install yarn
Yarn also prides itself on its speed and up until npm5 was released it really had the advantage.
Now, both package managers are alot closer to each other when comes to measuring install times. Have look at this comparison here for more detail.
The speed differences between these two now are less significant and most users really won’t be able to tell the difference. But there are other differences with npm5 which leads us into the next package manger.
The most notorious package manager, NPM (Node Package Manager) would be considered the most familiar for those within the dev community.
The npm team was also able to address some of its shortcomings with the release of npm5 back in May of this year.
These changes improved its speed significantly while also adding default lockfiles which enable all npm installs to be reproducible.
This means that previous discrepancies between users on different development environments are no longer having differing experiences with the same install
What may have previously thought as a bug was rather just two different versions installed of package. This has been rectified now.
Perhaps one of the most interesting package managers on this list, Turbo is a new NPM client that functions inside the browser. It claims to be 5X as fast as NPM and Yarn and you can look at its release post here.
Since it runs in the browser its predominantly used for Web IDE’s such as StackBlitz. One of the benefits claims to reduce the size of your node modules by half.
This is definitely one to watch as Web IDEs become faster and more reliable.
NuGet deals with all .NET assemblies so it is a very Microsoft focused package manager. It supports .NET native packages written in C++It is seamlessly integrated with Visual Studio and comes pre-installed with it.
Bower was originally created to be a specialized front end development package manager. Since then it has been made somewhat obseltete by changes to npm3 and Yarn.
While some have gone as far to consider it legacy, its quite dated in terms of functionality. It still meets the need of being a package manger but thats about it really.
Some have even called to see it depracted in order to make way for and encourage NPM + Webpack/Browserify workflows. You can have a look at that here
As with all branded tools for web developers there can by a lot of blind loyalty to one specific technology or in this case, package mangers.
From researching different aspects of whats out there I really don’t think any developer will go wrong choosing between NPM or Yarn. They seem to be the most feature rich of whats available and its very unlikely that you will need one over the other in your workflow.
Hopefully this cleared up some of the confusion around what package mangers suits your needs. I intend to update this blog a lot more regularly for 2018 while also getting the web app version sorted this month.