背景
Pipelines で e2e テスト実装した際に、npm install でたまにエラーになることがあった。
その際の対処法の記録
実際のエラー
Acquire の 設定漏れ?とか思っちゃうようなエラーだけど、
Resubmit を何回かすると解消しちゃう。
Pipelines の VM としては特に設定しなくても動くけど、ごくまれに失敗する。
ってことで、設定ではない、と思うんだけど、よくわからず・・
error
npm error code ECONNRESET
npm error errno ECONNRESET
npm error network Invalid response body while trying to fetch https://registry.npmjs.org/@fluentui%2freact-popover: aborted
npm error network This is a problem related to network connectivity.
npm error network In most cases you are behind a proxy or have bad network settings.
npm error network
npm error network If you are behind a proxy, please make sure that the
npm error network 'proxy' config is set properly. See: 'npm help config'
結論
bash で npm install をするのではなく、
task として用意されている npm を使う
script でやってた方法
- script: |
cd ./app/frontend
npm install
npm run build
displayName: 'build frontend'
専用 task を利用する
- task: Npm@1
inputs:
command: 'install'
workingDir: '$(System.DefaultWorkingDirectory)/app/frontend'
verbose: true
displayName: 'npm install'
- task: Npm@1
inputs:
command: 'custom'
workingDir: '$(System.DefaultWorkingDirectory)/app/frontend'
customCommand: 'run build'
displayName: 'npm run build'
エラー記録
npm error code ENOENT は、workingDir が未設定
フォルダ未設定エラー
npm error code ENOENT
npm error syscall open
npm error path /home/vsts/work/1/s/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/home/vsts/work/1/s/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
あとがき
現状、これで再発してない・・けど、どうなんでしょうね・・