DEV Community

Kapil Pandey
Kapil Pandey

Posted on • Updated on

[Solved] “Treating warnings as errors because of process.env.CI = true”

Did deploying your code to netlify failed and in logs you are getting
Treating warnings as errors because of process.env.CI = true
Error
If yes then you are at the right place. I'll help you fix this error within seconds. Before showing you the fix let's first have a glance at the root cause of this error.

What is this error all about?

Beginning on June 15, 2020, Netlify started a gradual rollout of adding the environment variable CI to build environments, with the value of true. This environment variable, short for Continuous Integration, is commonly set in various CI environments like Travis CI and Github Actions, among many others. The ecosystem has largely agreed to use this environment setting to detect when a build is executing in a CI environment, as opposed to a local development environment.

This setting allows many common libraries to detect a CI environment and change behavior accordingly. One such behavior is the disabling of progress “spinners” that while useful in a local development terminal, can render poorly when operating in a log streamed CI environment.

Because of this some libraries now interpret what were previously just warnings as hard errors and halt the build. The intention is that developers should not ship potentially broken configurations, but the downside is that builds that successfully completed previously started failing after this change.

The fix

If your build is breaking after this change, you can disable this behavior by unsetting the CI variable in your build. For example, the following will unset CI for the NPM command:
CI= npm run build

  • Log in to Netlify
  • Choose your app and click on Site settings
  • Navigate to Build & Deploy
  • Under Continuous Deployment select Edit settings
  • Update Build command to
CI= npm run build
       or
CI=false npm run build //OP mentioned below in comments
Enter fullscreen mode Exit fullscreen mode

If you are using netlify.toml to set the build command, update it as such:

...
  command = "CI= npm run build"
...
Enter fullscreen mode Exit fullscreen mode

*Rebuild you deployment
Now you should see Production: master@c215c12 Published 😉

Oldest comments (46)

Collapse
 
lucasrmagalhaes profile image
Lucas Magalhães

Thanks!! You saved me! I'm happy now. x)
covid19-pwa.netlify.app/

Collapse
 
kapi1 profile image
Kapil Pandey

Glad to be of some help!

Collapse
 
militusinnocent profile image
Militus

Hi, I'm almost completely new. I tried CI= npm run build but it didn't work, I guess I'm doing sth wrong. Any ideas on how to fix this on vercel?

Collapse
 
josiasaurel profile image
Josias Aurel • Edited

On vercel and netlify, setting CI to false in environment variables make it work XD

Collapse
 
ahmedsarhan profile image
Ahmed Sarhan

I just signed in to say thank you ... this saved my day

Thread Thread
 
chazkiker2 profile image
Chaz Kiker

retweet

Collapse
 
militusinnocent profile image
Militus • Edited

I did CI=false npm run build and it worked :)

Collapse
 
baxosh profile image
Bakhodir

Worked for me too

Collapse
 
saurabhdaswant profile image
saurabh daswant

yup worked for me too

Collapse
 
jmamadeu profile image
João Amadeu

Worked for me too, I tested on Vercel and Netlify.

Collapse
 
akinncar profile image
Akinn Rosa • Edited

works here on vercel deploy, nice job!

Collapse
 
angelisreis profile image
angelis-reis

Thanks o lot. Works like a charm, using: CI=false npm run build

Collapse
 
mrsaaddev profile image
mrsaadDev

thankyou!

Collapse
 
shivashankar_741 profile image
Shiva shankar

Big thanks to you

Collapse
 
robkaa profile image
RobK-AA

Just made an account to thank you for this!

Collapse
 
kelahkelah profile image
KelahKelah

Thanks. This solved the problem for me.
I used yarn and already had a yarn.lock file so automatically the Build command already had 'yarn build' so all i did was add CI = to the yarn build and it worked.
Like
Build command: CI= yarn build.

But for npm it would be
Build command: CI= npm run build

Collapse
 
justinpatel profile image
Justin Patel

Thanks, worked like a charm for me. 😉

Collapse
 
desdamo profile image
desdamo • Edited

Hello. I tried différents write but didn't work with vercel. Can you help me please?

"scripts": {
"start": "craco start",
"build": "CI='' yarn build",
"test": "craco test",

"eject": "react-scripts eject"
Enter fullscreen mode Exit fullscreen mode

},

Collapse
 
elminhoemmanuel profile image
Emmanuel Amodu

Thanks a lot just helped me after days of struggling...wheeww

Collapse
 
pixelagil profile image
Alejandro Vivas

Thank you!!

Collapse
 
sruthiragupathy profile image
sruthiragupathy

Thank you it helped

Collapse
 
adisking1 profile image
Aditya Narayan Sah

Fix

  • Log in to Netlify
  • Choose your app and click on Site settings
  • Navigate to Build & Deploy
  • Under Continuous Deployment select Edit settings
  • Scroll down to Environment variables and add a new Variable with the following values

CI = false