繁体   English   中英

cypress npm 包已安装,但缺少 Cypress 二进制文件

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

大家好,我是 azure devops CI 的新手,我正在尝试通过在作业之间缓存 node_modules 来减少我的管道构建时间,但是我遇到了这个我无法解决的错误。 我正在使用 cypress 进行测试。 这是我的天蓝色管道

# 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

您是否收到类似于以下内容的错误消息?

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.

如果是这样,根据错误日志,它提供了解决此问题的方法。 您可以尝试再次运行 cypress install 命令来解决问题。 这里有一个案例,你可以参考。

另外, “$(Agent.OS)”的引号应该类似于"$(Agent.OS)" 或者您可以选择在自托管代理中运行作业,机器级缓存和配置从运行到运行都保持不变,这可以提高速度。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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