如何在Azure Pipeline中向NPM添加--force标志

hmae6n7t  于 2023-08-06  发布在  其他
关注(0)|答案(2)|浏览(105)

我已经设置了一个Azure静态Web应用程序,我有一个Angular 13 Web应用程序,我想发布到它。因此,我将我的git提交推送到Azure DevOps,并且DevOps中的Azure管道(当我在Azure Portal中创建静态Web应用程序时自动创建)被触发。到目前为止一切顺利。然而,当管道尝试构建应用程序(NPM)时,它会给出一个错误。我知道,如果我强制构建,Web应用程序无论如何都可以工作,作为临时解决方案,这就是我想要做的。我一直在摆弄Azure Pipeline的YAML,试图添加--force标志,但一整天之后,我仍然无法让它工作。以下是Azure Pipeline的YAML:

name: Azure Static Web Apps CI/CD

pr:
  branches:
    include:
      - master
trigger:
  branches:
    include:
      - master

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: Azure-Static-Web-Apps-purple-grass-0e645d303-variable-group
  steps:
  - checkout: self
    submodules: true
  - task: AzureStaticWebApp@0
    inputs:
      azure_static_web_apps_api_token: $(AZURE_STATIC_WEB_APPS_API_TOKEN_PURPLE_GRASS_0E645D303)
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
      app_location: "/" # App source code path
      api_location: "" # Api source code path - optional
      output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######

字符串
如果有人能指出我可以在哪里添加--force标志,我会非常感激!

  • 谢谢-谢谢
pbossiut

pbossiut1#

要添加**--forceflag,可以在字段中添加自定义NPM build命令:app_build_commandAPI_build_command**。
举例来说:

- task: AzureStaticWebApp@0
    inputs:
      app_location: '/'
      api_location: 'api'
      app_build_command: 'npm install --force'
      output_location: ''
      api_build_command: 'npm install --force'
      azure_static_web_apps_api_token: $(deployment_token)

字符串
有关更多详细信息,您可以参考此文档:Build configuration for Azure Static Web Apps

xxslljrj

xxslljrj2#

触发器:

  • 发展

pool:vmImage:ubuntu-latest
步骤:

  • checkout:self子模块:真的
  • 任务:AzureStaticWebApp@0

输入:
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'

env:

Azure_static_web_apps_API_token:$(部署令牌)

NPM_CONFIG_FORCE:真实
NPM_CONFIG_LEGACY_PEER_DEPS:真实

相关问题