Azure Pipeline NPM Cache Missing Directory

Alex Ip 196 Reputation points
2021-08-03T13:56:50.107+00:00

The initial Cache task works resulting in a cache miss however on the last task step it fails because it cannot find the npm cache directory .npm.

Resolving key:
 - npm               [string]
 - "Linux"           [string]
 - package-lock.json [file] --> 16C3AA093A9902FA755EBC6ADE442B80EEDF06EF860BD68470595A881573918B
Resolved to: npm|"Linux"|wW2YKYRIcqdBYmbOF3HLiub4ie6oizIM/BpUA4ILc94=
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 20fd5b7d-d924-4b39-a3d8-f2519d5dec06
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `npm|"Linux"|wW2YKYRIcqdBYmbOF3HLiub4ie6oizIM/BpUA4ILc94=`
There is a cache miss.
tar: /home/vsts/work/1/.npm: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
ApplicationInsightsTelemetrySender correlated 1 events with X-TFS-Session 20fd5b7d-d924-4b39-a3d8-f2519d5dec06

As you can see "/home/vsts/work/1/.npm" does not exist under $(Pipeline.Workspace)/.npm

Is this located under a different directory within the agent?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
40,232 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vaibhav Chaudhari 38,756 Reputation points
    2021-08-03T14:35:04.123+00:00

    Hi Alex,

    Azure DevOps related questions are not supported on this forum. It's better to reach out to experts in a dedicated forum over here:

    https://developercommunity.visualstudio.com/spaces/21/index.html


    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Savinda Senevirathne 1 Reputation point
    2022-11-24T00:18:35.95+00:00

    Hi Alex,

    variables:
    npm_config_cache: $(Pipeline.Workspace)/.npm

    Overriding the npm_config_cache variable as above and then using it as the path to the cache resolved the issue for me.

    Source - https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#nodejsnpm

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.