I need to upgrade yarn 1.22.x to 3.8.3 in azure build pipeline. I have modified the pipeline yml file:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
checkLatest: true
script: corepack enable && yarn set version 3.8.3 && yarn install --network-timeout=1000000 --frozen-lockfile
displayName: Install dependencies
- pwsh: |
# yarn nx reset # Resets cache and nx daemon
yarn nx run-many --target=build --configuration production --projects="my-app"
displayName: Build
While running the build in azure devops pipeline I am getting below error
The lockfile would have been modified by this install, which is explicitly forbidden.
I can reproduce the issue using your yaml. The reason of the issue is that the yarn.lock
isn't updated when running yarn install
.
To resolve this issue, follow the steps below to create a new yarn.lock
file:
git clone <your repo url>
yarn.lock
from your project.corepack enable
, yarn set version 3.8.3
and yarn install
in the root folder of your project.yarn.lock
file will be created automatically. Push it into your Azure Repo. Then your pipeline should work as expected.If you don't want to update the yarn.lock
file in Azure repo and just want to upgrade yarn in the current pipeline, remove --frozen-lockfile
from your command, add an environment variable YARN_ENABLE_IMMUTABLE_INSTALLS
and set its value to false
. Then the pipeline will work.
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
- script: |
corepack enable
yarn set version 3.8.3
yarn install --network-timeout=1000000
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
You can see the same issue here for more details.