Oryx Pipeline fails when yarn is set to version 4.5.0
Bug Report
Pipeline
jobs:
- job: build_and_deploy_job
displayName: Build and Deploy Job
condition: or(eq(variables['Build.Reason'], 'Manual'),or(eq(variables['Build.Reason'], 'PullRequest'),eq(variables['Build.Reason'], 'IndividualCI')))
pool:
vmImage: ubuntu-latest
variables:
- group: {{hidden}}
steps:
- checkout: self
submodules: true
- script: |
corepack enable
yarn set version 4.5.0
yarn --version
displayName: 'Set up Yarn'
- task: AzureStaticWebApp@0
inputs:
azure_static_web_apps_api_token: ${{hidden}}
app_location: '/'
api_location: ''
output_location: ''
env:
NEXT_PUBLIC_API_URL: {{hidden}
We are using Node version 20 and Yarn 4.5.0 package.json
"engines": {
"node": "20.15.1",
"yarn": "4.5.0"
},
"packageManager": "[email protected]"
We also have the yarn location mentioned in a .yarn.yml file.
yarnPath: .yarn/releases/yarn-4.5.0.cjs
nodeLinker: node-modules
This is the error we are facing.
Using Node version:
v20.15.1
Using Yarn version:
4.5.0
Installing production dependencies in '/b744c23c-6a9c-4fb7-ab4d-83b7d8dd6fd9-swa-oryx/app/.oryx_prod_node_modules'...
Running 'yarn workspaces focus --all || yarn install --production'...
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module '/b744c23c-6a9c-4fb7-ab4d-83b7d8dd6fd9-swa-oryx/app/.oryx_prod_node_modules/.yarn/releases/yarn-4.5.0.cjs'
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.15.1
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module '/b744c23c-6a9c-4fb7-ab4d-83b7d8dd6fd9-swa-oryx/app/.oryx_prod_node_modules/.yarn/releases/yarn-4.5.0.cjs'
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.15.1
Does anyone have a way to get around this error?
Hi,
If this question is relevant by now I get around this problem by doing the build of the application within the script step. The relevant steps of my pipeline looks like this:
steps:
- checkout: self
submodules: true
- task: NodeTool@0
inputs:
versionSpec: '22.x'
checkLatest: true
displayName: 'Install Node.js'
- script: |
export BLOG_STATUSES_TO_SHOW_LIST=$(blogStatusToShow)
corepack enable
yarn set version stable
yarn install
yarn build
displayName: 'Install dependencies and build app'
- task: AzureStaticWebApp@0
inputs:
skip_app_build: true
skip_api_build: true
azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN)
production_branch: 'main'
app_location: "/public/" # path where the yarn build stores the app
api_location: ""
output_location: "public"
The package.json only contains this specific entries:
"engines": {
"node": ">=20.18.0"
},
"packageManager": "[email protected]"
}
the .yarnrc.yml only have one entry:
nodeLinker: node-modules
Of course this do not solve the Oryx problem itself but it works for me and so I hope this helps.
Hi,
If this question is relevant by now I get around this problem by doing the build of the application within the script step. The relevant steps of my pipeline looks like this:
steps: - checkout: self submodules: true - task: NodeTool@0 inputs: versionSpec: '22.x' checkLatest: true displayName: 'Install Node.js' - script: | export BLOG_STATUSES_TO_SHOW_LIST=$(blogStatusToShow) corepack enable yarn set version stable yarn install yarn build displayName: 'Install dependencies and build app' - task: AzureStaticWebApp@0 inputs: skip_app_build: true skip_api_build: true azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN) production_branch: 'main' app_location: "/public/" # path where the yarn build stores the app api_location: "" output_location: "public"The package.json only contains this specific entries:
"engines": { "node": ">=20.18.0" }, "packageManager": "[email protected]" }the .yarnrc.yml only have one entry:
nodeLinker: node-modulesOf course this do not solve the Oryx problem itself but it works for me and so I hope this helps.
how to make it work with the build commands reffering to env files. It works in my local flalessly with yarn 4.9.1, but oryx still refers to yarn 1.22 eg package.json build command alias "build:dev": "set 'GENERATE_SOURCEMAP=false' && env-cmd -f .env.dev react-scripts build" pipeline command
- task: AzureStaticWebApp@0 inputs: azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN) app_build_command: "yarn run build:dev"