Static-web-apps: Yarn 2 error building - The --prefer-offline flag is deprecated

Created on 18 Feb 2021  路  13Comments  路  Source: Azure/static-web-apps

After upgrading my react-create-app to Yarn 2 the following error occurs in the Build and Deploy job:

image

If a project is running Yarn 2 the command that should be used to install packages is 'yarn add --cached'

oryx

Most helpful comment

@Itrel This is not an official release from Oryx .. as the tag name says it's experimental and intended for internal testing purpose. I would recommend waiting for the official build. It will be there soon.

All 13 comments

@arroyc to investigate and provide temporary workaround if there is one.

Here is a temporary workaround that works for the above issue: use CUSTOM_BUILD_COMMAND flag, which can skip running package install command and run the custom build command provided, in this case yarn add --cached.

Hello, I'm having similar issue,
I'm using Azure/[email protected]

I've tried using the CUSTOM_BUILD_COMMAND workaround described by @qianz2 (I've tried setting it to yarn install and yarn add --cached, with and without the "" quote marks):

image

But it does not seem to effect it.

image

I can see the environment variable being passed in, might there be some reason why it's not making it to Oryx?

image

I've also tried to bypass the Installing production dependencies ... section here: https://github.com/microsoft/Oryx/blob/616edfb98a95927f0c31bc056f94a16fb18dcdcd/src/BuildScriptGenerator/Node/NodeBashBuildSnippet.sh.tpl#L46
by setting PRUNE_DEV_DEPENDENCIES but that does not seem to do anything either.

I am also encountering the yarn2 problem @caitlinwillmot mentioned. My attempts to pass in a CUSTOM_ BUILD_COMMAND is having the same problem @chriswoodle encountered.

The Oryx version in my build log is

Oryx Version: 0.2.20210225.1, Commit: ac3044e35d3dc78dce05ba4d552bbe144029a673, ReleaseTagName: 20210225.1

It was released 11 days ago (March 24)

Chri's Oryx log shows 0.2.20201112.1 which was released Nov 12, 2020

The latest Oryx release with Yarn 2 fixes is https://github.com/microsoft/Oryx/releases/tag/exp-20210306.4 and was released March 6, 2021.

When will Azure/[email protected] be updated to use Oryx version exp-20210306.4 ?

@Itrel This is not an official release from Oryx .. as the tag name says it's experimental and intended for internal testing purpose. I would recommend waiting for the official build. It will be there soon.

@Itrel we have an official release .. hope it will soon be updated in static web sites as well. https://github.com/microsoft/Oryx/releases

Excellent! Thank you very much.

Which repo/team should I go bug to update container
mcr.microsoft.com/appsvc/staticappsclient:stable

which is used by GitHub action
Azure/[email protected]

I thought this repo team would take care of updating that container image as well as the Oryx functionality.

@Itrel you are in the right place/repo .... i would just wait for their confirmation on updating their side... @anthonychu

For the Static Web Apps action, we integrate upstream changes from Oryx regularly and perform our own testing before releasing it. We don't have an exact ETA on when those changes will be available.

@Itrel For now, you can update your workflow to build your app in a separate step, and use the Static Web Apps GitHub action to deploy the app. To do this, set the app_location property of the action to the yarn build output. Also set skip_app_build to true.

I got the static site deployment working.
Attached is the GitHub workflow for my Gatsby multisite mono-repo with a PR off main.

The relevant steps are here and the full workflow file (.txt replacing .yml) is linked

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v2
with:
submodules: true

  - name: Setup node.js environment
    id: build
    uses: actions/[email protected]
    with:
      node-version: 12.x

  - name: install dependencies
    run: yarn install

  - name: Build SoftwareHardwareSystems
    run: yarn "build:SoftwareHardwareSystems"

  - name: Deploy SoftwareHardwareSystems
    id: deploy
    uses: Azure/[email protected]
    with:
      azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_POLITE_DESERT_02CBDA510 }}
      repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
      action: "upload"
      ###### Repository/Build Configurations - These values can be configured to match you app requirements. ######
      # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
      skip_app_build: true
      app_location: "/packages/SoftwareHardwareSystems/public" # App source code path
      ###### End of Repository/Build Configurations ######

azure-static-web-apps-polite-desert-02cbda510.txt

This should be fixed now.

Was this page helpful?
0 / 5 - 0 ratings