I have this issue on build task the second time I run the build pipeline without any changement in my code:
ENOENT: no such file or directory, open 'D:\a\1\s\src\client\node_modules.cache\angular-build-fonts\content-v2\sha512\20\92\5b910157b4a6180d92f5ea0232867edfcf77ed4095350c1a5dcc19600396b2386935fce40ebe9e2cf1d4c5051f07a3f5090c57e7b8f33f9cdae8fa62c139' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! prj@0.0.0 build:
ng build --configuration=production --prod --build-optimizer --optimization --aot
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the prj@0.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
As the first build worked correctly, I'm confident to think that the issue comes from the Azure Dev Ops caching. It's like the cache task doesn't save every thing from node_modules.
Here is the YML script (note, I use the classic editor):
variables:
NPM_PACKAGES: '$(Build.SourcesDirectory)/src/client/node_modules'
steps:
- task: Cache@2
displayName: 'Cache npm'
inputs:
key: 'npm | $(Agent.OS) | 5 | $(Build.SourcesDirectory)\src\client\package-lock.json'
path: '$(NPM_PACKAGES)'
cacheHitVar: 'NPM_CACHE_RESTORED'
- task: Npm@1
displayName: 'install -g npm@6.14.7'
inputs:
command: custom
verbose: false
customCommand: 'install -g npm@6.14.7'
- task: Npm@1
displayName: 'npm ci'
inputs:
command: ci
workingDir: src/client
verbose: false
condition: ne(variables.NPM_CACHE_RESTORED, 'true')
- task: Npm@1
displayName: 'run build'
inputs:
command: custom
workingDir: src/client
verbose: false
customCommand: 'run build --prod'
Note: I read that it's better to put in cache the cache folder than node_modules (https://docs.npmjs.com/cli/v8/commands/npm-cache) but not sure where is it. I added a task npm cache verify
to have more information, but still get There is a cache miss. return by post cache task, so I understood that C:\npm\cache is not found. Where is the npm cache folder on Azure Dev Ops? $(Pipeline.Workspace)/.npm (source: https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops#nodejsnpm) doesnt work either.
What do you suggest?