Reputation: 2397
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?
Upvotes: 9
Views: 4076
Reputation: 790
This is the document about Yarn global
yarn global is a prefix used for a number of commands like add, bin, list and remove. They behave identically to their normal versions except that they use a global directory to store packages. The global command makes executables available to use on your operating system
and this is the document about npm install global mode
In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.
I think there is no difference between them. Install a package as a global useful for developer tooling that is not part of any individual project but instead is used for local commands
Upvotes: -1
Reputation: 146530
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
How to display yarn globally installed packages?
See this thread as well
https://github.com/yarnpkg/yarn/issues/2049
Upvotes: 6