ENOENT:没有那个文件或目录,打开'/home/vsts/work/package.json'

Łuk*_*tal 5 yaml azure-devops azure-pipelines-release-pipeline angular

我在 git 中有 repo 并尝试在 vsts 中使用 yaml 进行构建。在存储库中只有新创建的 angular 项目,没有任何更改。当尝试使用默认的 angular yaml 运行管道时,我在运行“ng build --prod”时遇到以下错误

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install -g @angular/cli
    npm install
    ng build --prod
  displayName: 'npm install and build'


# Publish Artifacts
- task: PublishBuildArtifacts@1
  inputs:
    artifactName: dist
    pathtoPublish: 'dist'
Run Code Online (Sandbox Code Playgroud)

Łuk*_*tal 14

好的,我找到了答案。我需要添加:

workingDirectory: '$(Build.SourcesDirectory)/projectFolderName'
Run Code Online (Sandbox Code Playgroud)

以下:

displayName: 'npm install and build'
Run Code Online (Sandbox Code Playgroud)