Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any harm in using NPM and Yarn in the same project?

Tags:

yarnpkg

I have been using npm for a personal project and just recently stumbled across yarn. Would there be any harm or "intended side effects" to switching to yarn's package manager in the same project where I had been using npm?

like image 704
Dom Hallan Avatar asked Mar 31 '18 15:03

Dom Hallan


People also ask

Can we have npm and Yarn together?

Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node. js module resolution algorithm.

Does Yarn conflict with npm?

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.

Should I install Yarn with npm?

The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations. Use the -g flag with npm install to do this: sudo npm install -g yarn.


2 Answers

Although a few commenters here say its ok to mix both yarn and npm on the same project, after using yarn and npm and then yarn again, this is what yarn has to say about it:

warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution  inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. 
like image 85
Dave Pile Avatar answered Sep 21 '22 06:09

Dave Pile


Since to me it is not any harm to using both them into one project.

I use npm and yarn (50/50) in dev environment. But on ci/di i use only yarn because it is faster, and i reduce build minutes thanks yarn.

Also they both create different .lock file names.

like image 36
Artem Mirchenko Avatar answered Sep 17 '22 06:09

Artem Mirchenko