unable to run npm install --legacy-peer-deps in azurepipeline using static web app

Anonymous
2023-06-06T09:36:50.9233333+00:00

Hi there

I cant deploy a application in my Azure Static Web App using azurepipeline from Azure DevOps
I read about custom command in https://learn.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows%2Cclassic but this isnt work for me

this is the pipeline
User's image

when I run the pipeline Oryx tell me about the custom command OK
User's image

but Oryx doesnt run install --legacy-peer-deps

User's image

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
934 questions
0 comments No comments
{count} votes

Accepted answer
  1. brtrach-MSFT 16,356 Reputation points Microsoft Employee
    2023-06-07T03:32:13.68+00:00

    One thing you can try is to modify the app_build_command to npm install instead of install --legacy-peer-deps. This should work as Oryx automatically adds the --legacy-peer-deps flag when running npm install.

    If this does not work, you can try adding a custom command to your pipeline to run npm install --legacy-peer-deps before building your application. Here is an example of how you can modify your pipeline to include this command:

    - script: |
        npm install --legacy-peer-deps
        npm run build
      displayName: 'npm install and build'
    

    This will run npm install --legacy-peer-deps to install the dependencies with legacy peer dependencies and then run npm run build to build your application.

    Please reply back to this answer if you have any questions or if the above suggestions did not work.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Gautam Kumar 5 Reputation points
    2023-07-13T03:30:51.3733333+00:00

    It's works for me

    trigger:
      - develop
    
    pool:
      vmImage: ubuntu-latest
    
    steps:
      - checkout: self
        submodules: true
    
      - task: AzureStaticWebApp@0
        inputs:
          app_build_command: node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build -c develop --build-optimizer
          app_location: '/'
          api_location: 'api'
          output_location: 'dist/crm'
        env:
          azure_static_web_apps_api_token: $(deployment_token)
          NPM_CONFIG_FORCE: true
          NPM_CONFIG_LEGACY_PEER_DEPS: true
    
    1 person found this answer helpful.

  2. Anonymous
    2023-06-07T09:32:30.8133333+00:00

    Ok thanks it works!

    0 comments No comments

  3. Anonymous
    2023-06-07T09:32:31.23+00:00

    Ok thanks it works!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.