简体   繁体   中英

The cypress npm package is installed, but the Cypress binary is missing

Hello everyone i'm new with azure devops CI and i'm trying to reduice my pipeline build time by caching node_modules between jobs ,but i got this error that i can't resolve. i'm using cypress for testing. Here is my azure pipeline

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

pool:
  vmImage: 'windows-2019'

variables:
  npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- task: Cache@2
  inputs:
    key: 'npm | “$(Agent.OS)” | $(Build.SourcesDirectory)/package-lock.json'
    path: '$(Build.SourcesDirectory)/node_modules'
    cacheHitVar: 'CacheRestored'

- script: npm install
  displayName: 'npm install '
  condition: ne(variables['CacheRestored'], 'true')
  
- task: Npm@1
  inputs:
    command: 'custom'
    customCommand: 'run scripts'
  continueOnError: false  
  displayName: 'Npm run test'

- task: PublishBuildArtifacts@1
  displayName: "Publish Artifact: cypress-and-azure-devops Screenshots"
  inputs:
    PathtoPublish: cypress/screenshots
    ArtifactName: CypressAndAzureDevopsTestRunScreenshots
  condition: failed()

- task: PublishBuildArtifacts@1
  displayName: "Publish Artifact: cypress-and-azure-devops Videos "
  inputs:
    PathtoPublish: cypress/videos
    ArtifactName: CypressAndAzureDevopsTestRunVideos
  condition: succeededOrFailed()

- task: PublishTestResults@2
  displayName: "Publish Test Results"
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: "JUnit"
    testResultsFiles: "**/cypress-and-azure-devops-*.xml"
    failTaskOnFailedTests: true

Do you get the error message similar to the following?

The cypress npm package is installed, but the Cypress binary is missing.
We expected the binary to be installed here: /xxx/.cache/Cypress/4.8.0/Cypress/Cypress
Reasons it may be missing:
- You're caching 'node_modules' but are not caching this path: /xxx/.cache/Cypress
- You ran 'npm install' at an earlier build step but did not persist: /root/.cache/Cypress
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
Alternatively, you can run 'cypress install' to download the binary again.

If so, according to the error log, it provides a workaround to this problem. You can try to run the cypress install command again to fix the problem. Here is a case you can refer to.

In addition, the quotation mark of “$(Agent.OS)” should be like "$(Agent.OS)" . Or you can choose to run the jobs in self-hosted agent, machine-level caches and configuration persist from run to run, which can boost speed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM