Using Yarn (the npm replacement) on CircleCI

Yarn is an open-source package manager for JavaScript. Yarn is pre-installed on CircleCI and the packages it installs can be cached. This can potentially speed up builds but, more importantly, can reduce errors related to network connectivity.

Version Support

Ubuntu 14.04:0.27.5

Ubuntu 12.04:n/a

macOS:n/a

Setup

When CircleCI detects a JavaScript project, certain commands (like npm install or npm test) might be run. To use Yarn instead of npm, we override both the dependencies and test sections which prevents npm and other inferred commands from running.

dependencies:override:-yarntest:override:-yarn test

Overriding the dependencies phase means that the node_modules/.bin directory doesn’t get added to PATH. We add it in the machine phase.