I’m currently facing an issue with my project setup where the package-lock.json file resides in a subfolder of the project root, for example, subfolder/package-lock.json.
Within my YAML pipeline, I’m executing the Cache@2 task, but it’s failing because it can’t locate my package-lock.json file, despite the file’s existence. (I’ve confirmed this with a previous step that prints the files in the directory.)
Previously, before some refactoring, the package-lock.json file was located in the project root, and the following step worked with the default path:
parameters:
- name: npmConfigCache
type: string
default: "/home/vsts/.npm"
steps:
- task: Cache@2
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: ${{ parameters.npmConfigCache }}
displayName: Cache npm Packages
Here is how I call the template:
- template: npm/build-and-test.yml@templates
parameters:
npmConfigCache: "$(System.DefaultWorkingDirectory)/Subfolder/"
Has anyone encountered a similar issue before?
I’ve tried many different approaches
joseph aspey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.