cypress npm 包已安装,但缺少 Cypress 二进制文件 [英] The cypress npm package is installed, but the Cypress binary is missing

查看:176
本文介绍了cypress npm 包已安装,但缺少 Cypress 二进制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

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

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.

这篇关于cypress npm 包已安装,但缺少 Cypress 二进制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆