Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oryx Pipeline fails when yarn is set to version 4.5.0 #2528

Open
MattL-NZ opened this issue Oct 1, 2024 · 1 comment
Open

Oryx Pipeline fails when yarn is set to version 4.5.0 #2528

MattL-NZ opened this issue Oct 1, 2024 · 1 comment

Comments

@MattL-NZ
Copy link

MattL-NZ commented Oct 1, 2024

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?

@danielfeiler
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants