-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DevEx: use yarn instead of npm for installing dependencies #23566
Conversation
- faster - works offline - less mess over the lockfile
Test live: https://calypso.live/?branch=try/use-yarn |
As a general note yarn does not recommend installing from
https://yarnpkg.com/lang/en/docs/install/ Likely for OSX
Or for anyone with apt-get:
|
Did we also end up testing against npm ci ? That's likely to be available to Node LTS soon. |
Took a quick look at the bug list, and I think
cc @Automattic/jetpack if folks had any gotchas/insights |
I personally couldn't get the new version of |
To do:
|
Let's tie in this relevant discussion "Exploration: Drop yarn in favour of npm": Automattic/jetpack#8718 (thanks @simison) |
Offline supportBoth yarn and npm5 have offline support.
Lockfile
Here is a nice read about differences between In short:
SpeedThere used to be a huge difference in speed, but it seems like the differences are getting smaller. @Viper007Bond has a nice speed comparison script you can run: https://github.com/Viper007Bond/npm-yarn-benchmark Noting that NPM shrinkwrap and npm lockfile are equal concerning output so speed comparisons using Calypso should still be valid. Getting started -devexArguably, You could also keep using Aight, hope this info helps to decide! :-) |
I'd love to see this misconception die eventually. In theory, when you have a
All that said, I don't know if we still have to nuke the |
Ah, thanks @DanReyLop! I stand corrected: Both |
Yeah, almost! package-lock.json is never published, but a shrinkwrap will be. Libraries tend to use the package-lock.json to not force consumers into using exact dependencies, whereas a shrinkwrap is desirable for applications for its repeatability. See docs: https://docs.npmjs.com/files/package-lock.json
|
We don't need to if the npm install save works, but it does tend to fail a decent amount for us in wp-calypso. Folks also tend not to notice/understand the error message so it was safer to instruct folks to always use the our update-deps script. |
I don't think I understand that point. How could it be desirable for applications considering the difference only matters once published to npm? Applications don't get published to npm, they get deployed to servers |
We don't with wp-calypso but other folks might. Imagine, instead if our docker file did a
https://docs.npmjs.com/files/shrinkwrap.json This doesn't mean we can't move to a lockfile though :) since we don't do this. It just used to be that we could only lockdown deps previously with a shrinkwrap in older versions of npm. |
Ok I remember now. Since we use |
@DanReyLop: if |
It does, but we live with it. |
closing this due to a lack interest |
Use Yarn
We've considered switching to yarn in the past, but held off due to major improvements coming to npm. npm 5 is here, and was undoubtably much better than npm 3 and 4. So the question has become: is
npm5
better than yarn.Here are the features
yarn
supports that make it a no-brainer for me:yarn
can work offline with the commandyarn install --offline
. this is hugenode_modules
which is slow and forces us to halt working while it runs.yarn
handles its lockfile automaticallyyarn install
runs faster thannpm install
for the most common casespackage.json
has changed, and can early-return out of the install.performance comparison of yarn install vs. npm install
To test
Note: fixes #23348