【问题标题】:Selfhosted Azure DevOps Agent running as NetworkService not able to complete npm install and npm build作为网络服务运行的自托管 Azure DevOps 代理无法完成 npm install 和 npm build
【发布时间】:2022-06-14 18:19:24
【问题描述】:

在使用带有 Microsoft 和自托管代理的 windows 平台时,代理无法为 react 项目构建和生成构建文件夹,但在 ubuntu 上可以正常工作。

这是带有 Microsoft 代理的 linux yml 文件

https://gist.github.com/yogeswaran-gnrgy/0354d455e6c85d387281eb75d1a326f1

这是带有 Microsoft 代理的 windows yml 文件

https://gist.github.com/yogeswaran-gnrgy/816b9f06dbe0039c07ad1293d2fce141

这是使用 Microsoft 代理在构建步骤期间生成的日志 https://gist.github.com/yogeswaran-gnrgy/acbc3c2a268ea3b514cc423726b0a751

如果是自托管代理,它同时安装了 npm 和节点。可能是什么问题

【问题讨论】:

  • 通常当管道出现错误时,您应该在输出中注意到##[error]。我在您的日志中找不到错误。你确定管道没有完成吗?
  • 管道已完成,但没有构建文件夹。正如您可以在日志中查看的那样,没有“创建优化的生产构建日志”不知道是什么原因
  • 也许您不在源代码的正确文件夹中。在 npm run build 之前,导航到要使用 npm 构建的文件夹,或使用代理机器上的路径
  • 我试图验证这是否是只有自托管代理的问题,结果它也不适用于 Microsoft 托管代理。使用 ubuntu-latest 它可以正常工作并生成构建文件夹。当我使用 windows-latest 使用 Microsoft 托管代理时,它不会生成构建文件夹。我已将 yml 文件附加到 linux 和 windows 中。请检查我是否做错了什么。

标签: node.js reactjs azure azure-devops


【解决方案1】:

在 Linux 中

- script: |
    echo Executing install
    npm install
    echo Executing build
    npm run build
  displayName: 'Building the project'

当用作脚本时,npm install 和 npm build 只能在 Linux 中正常工作。对于windows,一定是这样的

- task: Npm@1
  displayName: 'Installing dependencies'
  inputs:
      verbose: false
      customCommand: install

- task: Npm@1
  displayName: 'Building the project'
  inputs:
      command: custom
      verbose: false
      customCommand: run build

【讨论】:

    猜你喜欢
    • 2023-04-10
    • 1970-01-01
    • 2020-06-12
    • 2016-05-01
    • 2021-06-06
    • 2020-05-16
    • 2021-11-14
    • 1970-01-01
    • 2021-10-31
    相关资源
    最近更新 更多