Monday, 19 October 2020

Nodejs Azure Deployment Failure: ENOENT: no such file or directory, stat '/home/site/wwwroot/node_modules/.bin/semver'

A couple days ago our production release pipeline started to fail with the following error:

2020-10-17T00:14:13.1233435Z Omitting next output lines...
2020-10-17T00:14:13.1234108Z Error: ENOENT: no such file or directory, stat '/home/site/wwwroot/node_modules/.bin/semver'
2020-10-17T00:14:13.1234825Z An error has occurred during web site deployment.
2020-10-17T00:14:13.1235127Z Kudu Sync failed
2020-10-17T00:14:13.1235451Z \n/opt/Kudu/Scripts/starter.sh "/home/site/deployments/tools/deploy.sh"
2020-10-17T00:14:13.1265401Z ##[error]Failed to deploy web package to App Service.
2020-10-17T00:14:13.1276348Z ##[error]Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
2020-10-17T00:14:13.6429241Z Successfully updated deployment History at https://{omitted}.scm.azurewebsites.net/api/deployments/{omitted}
2020-10-17T00:14:13.6510314Z ##[section]Finishing: Deploy Azure App Service

The pipeline will successfully complete all tests/scripts + publish the drop artifact. The release process starts but fails on the deployment step with the error above.

Pipeline image

I've attempted to roll back to the last working commit that did deploy successfully and it will still fail on this step.

I've spent a few days trying to resolve this and haven't had any luck. Any ideas would cause something like this to randomly start happening?

I can provide additional information about our stack if it'll help debug this.

EDIT

My current app settings:

App settings

azure-pipelines.yml

trigger:
- master

variables:

  # Azure Resource Manager connection created during pipeline creation
  azureSubscription: '9690121f-a50b-43c0-8d1b-e8ca6533b2d5'
  
  # Web app name
  webAppName: 'hidden'
  
  # Environment name
  environmentName: 'hidden'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
      
    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '12.x'
      displayName: 'Install Node.js'

    - task: YarnInstaller@3
      inputs:
        versionSpec: '1.22.4'
      displayName: 'Install Yarn'

    - script: |
        yarn install
        yarn build
        yarn test:e2e
      displayName: 'Build and test'
      
    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(environmentName)
    pool: 
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:
          steps:            
          - task: AzureWebApp@1
            displayName: 'Azure Web App Deploy: hidden'
            inputs:
              azureSubscription: '$(azureSubscription)'
              appType: 'webAppLinux'
              appName: '$(webAppName)'
              package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              runtimeStack: 'NODE|12.x'
              startUpCommand: 'node dist/main'


from Nodejs Azure Deployment Failure: ENOENT: no such file or directory, stat '/home/site/wwwroot/node_modules/.bin/semver'

No comments:

Post a Comment