Any Conflicts With Running Both NPM and Yarn Globally

I have been using NPM exclusively for my projects and was assigned another project that requires using Yarn. I need to have support for both and will frequently switch back and forth on projects.

Are there any known issues with installing yarn globally and still using NPM on other projects?

1 answer

  • answered 2021-03-08 18:36 Hrishikesh Kale

    super awesome, there are no such conflicts using yarn and npm together. because yarn and npm both have different installation directories.

    for global packages, you can use both, but don't forget to stick to one. we use yarn for our production.

    for non-global packages, it is beneficial to stick to what the project author uses. it becomes difficult sometimes if you have yarn.lock and package.lock file together, because there is a risk of being out of sync. for example, someone updated one package using yarn, someone will not get that changes who use npm and so on.

    Yarn and npm are interchangeable. As long as you use the same one each time, there is no difference between them. They have different install directories, which is why they can't be used together. Yarn will install a package, npm can't find it. npm will install a package, yarn can't find it.

    it is a more beneficial and good habit to use one package for each project to make sure that all packages are installed correctly, Having half your packages installed with yarn will stop npm start from working; having half your packages installed with npm will stop yarn start from working.

    also always use the same one for global too, it does not matter what you use yarn or npm. it does not matter to your global install.