1
votes

I'm trying to cache my npm dependencies using the Cache task in Azure Pipelines. I'm using Azure DevOps Server 2020. When the pipeline runs I get the following error message:

Resolving key:
 - npm                          [string]
 - "Windows_NT"                 [string]
 - Web/package-lock.json [file] --> 118CDFE1CFD866ABF2489C955D015ED5D2962A76602B6B544D996C46B84
Resolved to: npm|"Windows_NT"|1C9oHznmI3rlvpEvjwhi+Ssx/V05b9WttZRq
Resolving restore key:
 - npm          [string]
 - "Windows_NT" [string]
Resolved to: npm|"Windows_NT"|**
Information, Getting a pipeline cache artifact with the following fingerprint: `npm|"Windows_NT"|1C9oHznmI3rlvpEvjwhi+Ssx/V05b9WttZRqxHYD+2w=`.
##[error]API resource location a7c78d38-31a8-417e-ba6b-7e58b352f304 is not registered on https://[azure_devops_url]/DefaultCollection/.

Here is part of my pipeline YAML:

variables:
    npm_config_cache: $(Pipeline.Workspace)/Web/.npm
steps:
  - task: NodeTool@0
    displayName: 'Use Node 14.15.0'
    inputs:
      versionSpec: 14.15.0
      checkLatest: false
  - task: Cache@2
    displayName: 'Cache NPM packages'
    inputs:
      key: 'npm | "$(Agent.OS)" | Web/package-lock.json'
      restoreKeys: |
        npm | "$(Agent.OS)"
      path: $(npm_config_cache)
  - script: npm ci

I install my npm packages in a subfolder. How do I solve the error?

1
You're using private agents; packages are implicitly cached as long as you don't clean the working folder between builds. This feature is really intended primarily for the hosted agent in Azure DevOps Cloud, where there is nothing persisted between builds.Daniel Mann
My packages are not cached between builds. The nodejs install gets cached.mdailey77
I checked the Microsoft documentation. Caching of npm packages is done with the cache task. I don't clean the working folder between builds and the pipeline installs the npm packages every time. I need the cache task but it doesn't work in DevOps Server 2020.mdailey77

1 Answers

1
votes

It looks that this is not supported on premises. Please check this GitHub issue.