【问题标题】:Cypress Github Action Fail赛普拉斯 Github 操作失败
【发布时间】:2021-10-23 08:29:35
【问题描述】:

我将 GitHub Action 用于 CI/CD,我从中编写了一些 cypress 测试和 YAML 文件。但是当我推送存储库时出现错误。

name: Cypress Tests

# Controls when the workflow will run
on:
 # Triggers the workflow on push or pull request events but only for the main branch
push:
  branches: [ main ]

jobs:
  cypress-run:
    runs-on: ubuntu-latest
     steps:
      - name: Checkout
     uses: actions/checkout@v2
     # Install NPM dependencies, cache them correctly
     # and run all Cypress tests
     - name: Cypress run
       uses: cypress-io/github-action@v2
       with:
         build: npm run build
         start: npm start

失败的错误

./src/App.scss
Node Sass version 6.0.1 is incompatible with ^4.0.0 || ^5.0.0.


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reversed-spider-solitaire@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the reversed-spider-solitaire@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output 
above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-08-22T20_28_01_743Z-debug.log

Error: The process '/usr/local/bin/npm' failed with exit code 1

我如何解决这个问题。当我在本地运行柏树时,它可以正常工作。

【问题讨论】:

    标签: reactjs yaml cypress github-actions


    【解决方案1】:

    您需要先设置 Node 版本。

    - name: Setup Node
          uses: actions/setup-node@v1
          with:
            node-version: 15
    

    【讨论】:

    • 错误:进程 '/opt/hostedtoolcache/node/15.14.0/x64/bin/npm' 失败,退出代码现在我得到了这个错误
    【解决方案2】:

    该问题与 github 操作没有直接关系,而是与 cypress 操作使用的节点版本相关,该操作从缓存中提取它,以及您在应用程序中使用的节点 sass 版本。根据错误消息,您应该能够根据节点 sass 包自述文件 https://www.npmjs.com/package/node-sass

    使用 12 到 16(最新)之间的任何节点版本

    欲了解更多信息,请查看此帖子Error: Node Sass version 5.0.0 is incompatible with ^4.0.0

    您可以在此演示中看到 cypress 使用操作示例正常工作,这让您知道这不是 github 操作或 cypress 设置https://github.com/meroware/demo-cypress-github-action

    进行以下更改,您应该一切顺利

    name: Cypress Tests
    on:
      push:
        branches: [ main ]
    jobs:
      cypress-run:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout
            uses: actions/checkout@v2
          - name: Setup Node
            uses: actions/setup-node@v1
            with:
              node-version: 14 # but you can do 12-16
          - name: Cypress run
            uses: cypress-io/github-action@v2.3.6
            with:
              build: npm run build
              start: npm start
    

    【讨论】:

    • 我改了,但文件中出现了同样的错误
    • 错误:进程 '/opt/hostedtoolcache/node/15.14.0/x64/bin/npm' 失败,退出代码
    • 这是 cypress 操作的错误。使用最新版本 2.3.6,如果您发现任何其他问题,请告诉我。更新上面的示例以使用最新的操作版本
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 2022-08-22
    • 2021-10-28
    相关资源
    最近更新 更多