Recently my Azure DevOps build pipeline failed because Azure is using npm 8.x, which will have issue for angular projects when running `npm install`.  This is a known issue which can be solved by using `--legacy-peer-deps` or `--force` for the `npm install` command. However, Azure DevOps's npm task is not taking parameters by default. Let's see how we can use these parameters in Azure DevOps.

Old YAML file


  - task: Npm@1
    displayName: 'npm install'
    inputs:
      workingDir: '$(System.DefaultWorkingDirectory)/src/Web/work996'
      command: 'install'

It produces error:

Custom Command


To solve this issue. We need to use custom command for the npm task.

  - task: Npm@1
    displayName: 'npm install with legacy-peer-deps'
    inputs:
      workingDir: '$(System.DefaultWorkingDirectory)/src/Web/work996'
      command: 'custom'
      customCommand: 'install --legacy-peer-deps'

Now the build will work fine.