Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between brew, yarn, and npm?

I was using the react-native package which I installed globally with npm. Now it says at the first line after executing the init command. The following:

Installing react-native from npm... Consider installing yarn to make this faster: https://yarnpkg.com 

So I was checking that website and it looked interesting to me, but I don't exactly know what it would be. At first, I thought that I would need brew to install yarn, so I could yarn to install npm. But now I think that yarn is a replacement of npm. Is that a correct statement?

Why would I like to have so many package managers?

I understand that it's useful for software like Atom or Visual Studio Code to have their own package manager. But for development, I do not see the reason why someone would like to use four different package managers (brew for 'primary software', yarn for npm packages, npm for backend modules and bower for front-end libraries). How can this package manager forest be untangled?

like image 634
user007 Avatar asked Nov 03 '16 08:11

user007


People also ask

What is the difference between Yarn and npm?

Yarn verifies packages with checksum, while NPM uses SHA-512 (Secure Hash Algorithm) stored in the package-lock. json file. Security threats were a significant issue in early versions of NPM. As of version 6, NPM performs a security audit every time you install a package.

Which is better Yarn or npm?

As previously stated, Yarn installs dependency packages in parallel, whereas NPM installs them sequentially. As a result, Yarn outperforms NPM when installing bigger files. Both tools can save dependent files to the offline cache.

Is Yarn better than npm 2022?

In terms of speed and performance Yarn is better than NPM because it performs parallel installation. Yarn is still more secure than NPM. However, Yarn uses more disk space than NPM.


1 Answers

I am not familiar with brew, but I suppose you mean the Homebrew software package management system for macOS.

Then the purpose of each system is:

  1. brew: installation of software, i.e. ready to consume applications like wget.
  2. npm: installation of packages (libraries), i.e. pieces of functionality to help you build your own applications.
  3. yarn: also installation of packages.

Yarn has some advantages over npm, the main two are the speed and the predictability. Yarn reuses the npm's package.json file and doesn't change its structure. Therefore you can run yarn install instead of npm install and theoretically everything will work automatically.

P.S. I agree, https://yarnpkg.com doesn't have enough background on why the hell we need another package management system, but there is a great article which fills that gap.

like image 170
Monsignor Avatar answered Oct 02 '22 17:10

Monsignor