Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yarn npm global modules

In the past I used npm to install some modules globally. Now that I've started a new project I want to begin using yarn.

I'm confused what will happen if I install a new module globally using yarn. Will yarn convert the global node_modules directory ? Or do you I have to delete the global directory and reinstall each module ?

like image 800
Tomek Dobrzynski Avatar asked Dec 04 '25 14:12

Tomek Dobrzynski


1 Answers

NPM

  • bin is linked into $(npm prefix -g)/bin
  • module is installed into $(npm prefix -g)/lib/node_modules

YARN

  • bin is linked into yarn global bin
  • module is installed into yarn global dir

You can config yarn to use the configuration of npm:

  • config bin , yarn config set prefix $(npm prefix -g)
  • config module, I don't recommend you config yarn to use the path which npm uses, it will delete npm even,after you intall a package globally.

    if you dare,try below

    yarn global add react --global-folder $(npm prefix -g)/lib

like image 157
briefy Avatar answered Dec 07 '25 08:12

briefy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!