How to use latest version of yarn in pipeline? npm install yarn failing
Asked by Drew Gallagher:

I am trying to use the latest version of yarn configured locally also in my pipeline.

I upgraded our node image to version 18 in hopes that would use the latest version of yarn.

Once that didn't work I added a script command in our step to install yarn and it keeps failing and using the old version of yarn.

I am trying to use the latest version of yarn configured locally also in my pipeline.

I upgraded our node image to version 18 in hopes that would use the latest version of yarn.

Once that didn't work I added a script command in our step to install yarn and it keeps failing and using the old version of yarn.

```
image: node:18

definitions:

steps:

 - step: &yarnInstall

name: Yarn Install

script:

 - npm install yarn

 - yarn

 - step: &test

name: Test

script:

 - yarn test --detectOpenHandles --forceExit --changedSince $BITBUCKET_COMMIT

 - step: &build

name: Build

size: 2x

script:

 - NODE_ENV=${BUILD_ENV} yarn build

artifacts:

 - build/**

 - step: &deploy_s3

name: Deploy to S3

script:

 - pipe: atlassian/aws-s3-deploy:0.3.8

variables:

AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID

AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY

AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION

S3_BUCKET: $S3_BUCKET

LOCAL_PATH: "./build/"

ACL: 'public-read'

 - step: &auto_merge_down

name: Auto Merge Down

script:

 - ./autoMerge.sh stage || true

 - ./autoMerge.sh dev || true

caches:

jest: /tmp/jest_*

# although bitbucket-pipelines provides a predefined node cache

# upon research and running the pipeline, it does not cache

# for the yarn install command and does not improve performance

# from the comments on bitbucket forums, no one is sure why exactly

# so we need a custom node cache

node-custom: ./node_modules

pipelines:

branches:

feature/1204050745005198:

 - step:

caches:

 - node-custom

<<: *yarnInstall

 - parallel:

fail-fast: true

steps:

 - step:

caches:

 - node-custom

 - jest

<<: *test

 - step:

caches:

 - node-custom

<<: *build

deployment: Release Env

 - step:

<<: *deploy_s3

deployment: Release

dev:

 - step:

caches:

 - node-custom

<<: *yarnInstall

 - parallel:

fail-fast: true

steps:

 - step:

caches:

 - node-custom

 - jest

<<: *test

 - step:

caches:

 - node-custom

<<: *build

deployment: Dev Env

 - step:

<<: *deploy_s3

deployment: Dev

stage:

 - step:

caches:

 - node-custom

<<: *yarnInstall

 - parallel:

fail-fast: true

steps:

 - step:

caches:

 - node-custom

 - jest

<<: *test

 - step:

caches:

 - node-custom

<<: *build

deployment: Staging Env

 - step:

<<: *deploy_s3

deployment: Staging

prod:

 - step:

caches:

 - node-custom

 - jest

<<: *yarnInstall

 - parallel:

fail-fast: true

steps:

 - step:

caches:

 - node-custom

 - jest

<<: *test

 - step:

caches:

 - node-custom

<<: *build

deployment: Production Env

 - parallel:

steps:

 - step:

<<: *deploy_s3

deployment: Production

 - step:

<<: *auto_merge_down

```

Attached is a screenshot of the run. ![Screen Shot 2023-02-22 at 12.26.39 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/241744i94797BE6E8A1227C/image-size/large?v=v2&px=999 "Screen Shot 2023-02-22 at 12.26.39 PM.png")


Answers:
author: Drew Gallagher
body: Actually running

```
yarn set version latest
```

sets the version to latest without running an install command


Tags: bitbucket-cloud

bitbucket-pipelines

cloud

node

yarn