Github的行动不是建立React应用程序

问题描述

当我建立(npm run build “脚本”:{ “ build”:“反应脚本build --passWithNoTests” }

pc上的

)项目,它已成功构建。 但是当我推送更改时,构建过程在github上失败

> log@0.1.0 build /home/runner/work/project/project
> react-scripts build --passWithNoTests

Creating an optimized production build...

Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.

Failed to compile.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! log@0.1.0 build: `react-scripts build --passWithNoTests`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the log@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/2020-08-17T06_51_55_527Z-debug.log
##[error]Process completed with exit code 1.

这是yml文件

name: Node.js CI
on:
  push:
    branches: [ test ]
  pull_request:
    branches: [ test ]

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x,12.x,14.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
      
    - name: clean cache
      run: npm cache clean --force
    - name: install
      run: npm ci
    - name: npm install
      run: npm install
    - name: build
      run: npm run test --if-present

我该怎么办?

解决方法

GitHub动作使用CI自动设置了true环境变量。因此,将警告视为错误。您可以尝试如下操作。

- name: build
  run: npm run test --if-present
  env:
     CI: false

快乐的自动化!

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...