npm install命令在基本angular应用程序的Azure构建管道中失败

bxjv4tth  于 2023-08-06  发布在  Angular
关注(0)|答案(1)|浏览(124)

1.已将this GitHub存储库导入Azure存储库。
1.使用经典编辑器创建了构建管道,其YAML代码如下:

trigger:
  branches:
    include:
    - refs/heads/master
jobs:
- job: Job_1
  displayName: Agent job 1
  pool:
    vmImage: ubuntu-latest
  steps:
  - checkout: self
    fetchDepth: 1
  - task: Npm@1
    displayName: npm install
    inputs:
      workingDir: package.json
      verbose: false
  - task: Npm@1
    displayName: npm custom
    inputs:
      command: custom
      workingDir: package.json
      verbose: false
      customCommand: npm run build
  - task: ArchiveFiles@2
    displayName: Archive $(Build.BinariesDirectory)
  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: drop'

字符串
不确定,出了什么问题。运行管道时,npm install步骤中出现错误:


的数据

文本错误

Starting: npm install
==============================================================================
Task         : npm
Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.
Version      : 1.221.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm
==============================================================================
/usr/local/bin/npm --version
9.5.1
##[error]Error: ENOTDIR: not a directory, stat '/home/vsts/work/1/s/package.json/.npmrc'

pxy2qtax

pxy2qtax1#

为了让你的YAML管道从你的存储库中读取代码,你需要使用predefined variables为了从存储库中读取你的文件,你需要在你的代码中使用$(System.DefaultWorkingDirectory)
当我尝试使用package.json甚至$(System.DefaultWorkingDirectory)/package.json时,我收到了相同的错误代码:
x1c 0d1x的数据
现在,我使用下面的代码-1和它的工作成功,参考下面:-

trigger:
- master

pool:
  vmImage: ubuntu-latest

steps:
  - checkout: self
    fetchDepth: 1
  - task: Npm@1
    displayName: npm install
    inputs:
      workingDir: $(System.DefaultWorkingDirectory)
      verbose: false
  - task: ArchiveFiles@2
    displayName: Archive $(Build.BinariesDirectory)
  - task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: drop'

字符串

输出:-


代码-2:-

trigger:
- master

pool:
  vmImage: ubuntu-latest

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

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

- task: ArchiveFiles@2
  displayName: Archive $(Build.BinariesDirectory)

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

输出:-


相关问题