解决使用jenkins构建react项目失败

解决使用jenkins构建react项目失败

Jenkins构建react项目失败,报错如下:

yarn build 
yarn run v1.22.17
$ node scripts/build.js
Creating an optimized production build...

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

Failed to compile.

./src/pages/sacrifice/index.jsx
  Line 1:17:      'PureComponent' is defined but never used    

....省略一堆错误
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

Treating warnings as errors because process.env.CI = true.CI模式会把所有的warning当做errors处理,所以在服务器上自动执行命令会报错,我们只要把所有的warning解决掉就可以了。

解决方法

设置系统变量:

process.env.CI = false;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐