Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between installing global packages with Yarn or NPM?

Tags:

npm

yarnpkg

Does it matter whether you install a global package with yarn global add PACKAGE vs npm install -g PACKAGE ?

Is there any difference at all, like where files are installed? If yes, what is it?

like image 522
Andreas Avatar asked Jul 08 '19 19:07

Andreas


People also ask

Is there a difference between npm install and Yarn install?

The main difference between NPM and Yarn is the package installation process. Yarn installs packages in parallel. Yarn is optimized to fetch and install multiple packages at once. NPM will perform a serial installation process.

Should I install Yarn globally?

The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations.

Should I install packages globally npm?

A package should be installed globally when it provides an executable command that you run from the shell (CLI), and it's reused across projects. You can also install executable commands locally and run them using npx, but some packages are just better installed globally.

Is Yarn still 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

So yes, you are right it is different. For npm it is something like below

/Users/tarunlalwani/.nvm/versions/node/v9.2.0/lib if you are using nvm

You can get this path using

$ npm config get prefix
/Users/tarunlalwani/.nvm/versions/node/v9.2.0

Where does npm install packages?

While yarn uses other paths

  • Windows: %LOCALAPPDATA%/Yarn/config/global
  • OSX and Linux non-root: ~/.config/yarn/global
  • Linux if logged in as root: /usr/local/share/.config/yarn/global

How to display yarn globally installed packages?

See this thread as well

https://github.com/yarnpkg/yarn/issues/2049

like image 171
Tarun Lalwani Avatar answered Sep 19 '22 07:09

Tarun Lalwani