Preinstall Yarn



Yarn is a JS packager manager that is similar to the npm CLI program but much faster and more reliable. Yarn also supports offline installation of packages if your dependency tarballs are committed to Git, which is great for CI since tests and builds will succeed even if the npm registry goes down. It is shaping up to be pretty popular and got 7k stars and counting on GitHub under 24 hours.

Could CircleCI preinstall Yarn by default so everyone doesn’t need to install it manually?

Cache YARN properly?
Ng: command not found (angular-cli & yarn)

Would love this. In CI, npm install times count a lot!


+1 - I’m finding Yarn to be much quicker for installs than standard NPM.


Agreed. However, even with having to install Yarn each time we’ve shaved minutes off our build times. I wrote a quick guide on how you can swap over to yarn.

Yarn install hangs and never completes

Great guide, thanks for writing it. Would you like to add in the steps to cache the ~/.yarn-cache directory?


Done! I updated the gist in the guide.


There’s some instructions on the Yarn site about how to use it on CircleCI (, but having Yarn preinstalled would be awesome :smiley:


Here is what we’re doing:

Shell script to install specific version of npm or yarn.

shell file below is ./scripts/misc/installPackageManager

set -e
set -o pipefail

# first, make sure you have latest npm/yarn

# if you want pure latest npm then `npm show npm version`
LATEST_PACKAGE_MANAGER=`npm show $PM@$PM_VERSION version | tail -n 1 | awk '{print $2}'`

  npm install -g $PM@$PM_VERSION

Then in circle.yml

    - mkdir ~/.yarn-cache
    version: v4.6.1

    - ./scripts/misc/installPackageManager && yarn install
    - ~/.yarn-cache

    - yarn test


Thanks so much for the suggestion and thank you to the community for the overwhelming feedback for this.

I am working with our image team to try to get this rolled out in the next image release. Hope to have an update for everyone here soon!


This is something that we have rolled out, please see our docs for details.


I don’t understand how this is simpler or more useful than the traditional hacky way. I really hoped that I could simply use yarn: true somewhere and override the dependencies & test sections with yarn install and yarn test. It’s still simpler to cache the yarn cache dir and install it by running sudo apt-get update && sudo apt-get install yarn which takes less than 10 seconds.


Me neither, I was also under the impression that implementation would be that the inference things would see a yarn.lock and say, oh, do it the yarn way, … I’m going to do those yarn things.


I’ve updated circle.yml as described, but it’s not working, since yarn command not found.

yarn install
bash: line 1: yarn: command not found

yarn install returned exit code 127

Action failed: yarn install



Please check your Starting container step. You may be on our 12.04 build image, which we are no longer updating due to it being EOL very soon.


Did you try removing your custom apt-get installation and rebuild without cache?


I’ve added custom apt-get installation after posting problem here.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.