1
votes

I have a pipeline setup in Azure Devops to build an Angular application. The pipeline is setup such that I cache the npm packages. This pipeline worked fine for several months, but now it isn't recognizing angular when there is a cache hit. If I disable the cache step it works like normal. I have the same issue happening on 2 pieplines and figure something has changed in the azure dev ops backend. I attempted to add a step that would install Angular in the event that there was a cache hit, but the same issue still persisted.

Image of error message

Image of Cache Setup

1
Did you find out what is causing this? In our pipeline, it goes through the first time when there is no cache. The second run where it gets the cache and skips the install - the build step fails with the same output you are experiencingJohan Aspeling
@Johan Aspeling I wound up turning off caching for about a week and when I re-enabled it everything went to working correctly. I think if you can find where Azure stores the cache and delete it, it may help. I also changed from using npm i to npm ci, which is made specifically for continuous integration, I'm not sure if that changed anything or not.dmoore1181
Interesting, caches get removed after 7 days - and you can't force delete them. Maybe that's why yours started working again? The problem I think I have is we are running on multiple agents. If it caches on one agent and runs the next pipeline on that agent, it works. It fails with the above error when running the pipeline consecutively on a different agent... Which makes sense, because then it cant find 'ng' in the 'cached' node_modules. Just annoying...Johan Aspeling

1 Answers

0
votes

This is because you need to have angular cli installed globally to have it recognized as a command:

npm install -g @angular/cli

But if you still want to have this installed locally please take a look here:

To run a locally installed version of the angular-cli, you can call ng commands directly by adding the .bin folder within your local node_modules folder to your PATH. The node_modules and .bin folders are created in the directory where npm install @angular/cli was run upon completion of the install command.