node.js - Github 的操作不是构建 React 应用程序
问题描述
当我构建时 (npm run build "scripts": { "build": "react-scripts 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 ActionsCI
使用true
. 因此将警告视为错误。您可以尝试如下。
- name: build
run: npm run test --if-present
env:
CI: false
快乐的自动化!
推荐阅读
- reactjs - 为什么我需要两次 renderToString 才能反应服务器端渲染?
- oracle - 如何使用 Oracle (XMLELEMENT) 中的触发器更新 XML 节点
- python - Numpy 命令不像 3 周前那样工作
- apache-kafka - state.dir 目录是在代理端还是应用端?
- bash - 通过标准输入处理输入时出现意外行为,但文件输入工作正常
- scala - 播放框架 akka 流 websocket 处理消息被发送到死信
- c - 可以 fnctl(F_SETOWN,
) 将信号定向到 pthread ID 而不是进程 ID? - echarts - 在 eCharts 中更改热图中的颜色
- javascript - 存根位于另一个对象构造函数中的对象
- gulp - Gulp-less 4.0.1 和 Gulp 4.0.0 不创建输出 css