At a client, we’re converting all projects (i.e., sites, services, libraries) from npm to yarn. Mostly for the speed (as it uses the internal cache).
Step by step guide
- Install yarn in your local environment * https://yarnpkg.com/lang/en/docs/install/
- Run
yarn install* This will create ayarn.lockfile * Add that file to the repo:git add yarn.lock - Modify Dockerfile
* Install yarn (in the Dockerfile). Idea: shortcut this execution with
yarn --versionin case it is installed * Configure the PATH variable (ENV PATH …) *ADD yarn.lock* Replacenpm installwithyarn install - Modify pipeline
* See example (below)
*
install_yarn. Idea: shortcut this execution withyarn --versionin case it is installed * Replacenpm installwithyarn install - Test it
Jenkins
Build step: execute shell
function install_yarn {
yarn --version || curl -o- -L https://yarnpkg.com/install.sh | bash
export PATH="$HOME/.yarn/bin:$PATH"
}
install_yarn
yarn install