问题描述
当我建立(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
快乐的自动化!