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 😉

Latest comments (46)

Collapse
 
nathaliejanep profile image
Nathalie Persson Enriquez

CI= npm run build worked for me:)))))

Collapse
 
saeidatashin profile image
saeidAtashin

perfect

Collapse
 
onukwilip profile image
Prince

Wow thanks! I did CI=false npm run build and it worked fine 😁😁. I wish i had known this sooner, i had to commit my node_modules folder to github before i found this solution 😥

Collapse
 
raymartevangelista profile image
Raymart Evangelista

Worked for me too!

Collapse
 
thangtruong1808 profile image
Thang Truong

Hi Everyone,

CI= npm run build
Enter fullscreen mode Exit fullscreen mode

This worked well.

Thanks

Collapse
 
ushashir profile image
Ushahemba Shir

This worked for me

Collapse
 
ervidaslaven profile image
Slaven Đervida

Thank you so much! Works for me. 😄

Collapse
 
miconley profile image
Michael Conley

Simple workaround but devs should be sure to re-enable this feature prior to launch.

Collapse
 
overmartinezglobant profile image
Over Martinez

Hi everyone!
I'm getting an error with CI but with the test commands, I have this in my package.json:

"test": "TZ=UTC razzle test --env=jsdom",
"test:ci": "CI=true yarn test",
Enter fullscreen mode Exit fullscreen mode

When I run on my local machine the command yarn run test it works perfectliy fine on all tests, however when I run yarn run test:ci sometimes it fails 1 or 2 tests sometimes pass all of them, the results are so random.

According to what all of you are saying here, I changed "CI=false ... but still the same

Someone can help me!? 🙏

Collapse
 
likelionsungguk profile image
Sungguk Cho

THANKS !!

CI=false npm run build
working in gitlab ci
but in other cases, i think
Ci='' would be good
because sometimes the false string means true not false

reference below
docs.netlify.com/configure-builds/...

Collapse
 
juxnpxblo profile image
juan

ty! worked for me deploying a react app to vercel
just override the build command with CI= npm run build

Collapse
 
varvay profile image
Varid Vaya Yusuf • Edited

Hi @kapi1 Im wondering what's the drawback when we disable the CI option? Is this flag only treats warning as error or it serve another purpose?

Collapse
 
nitika1111 profile image
Nitika Sharma

It worked! Thanks :)

Collapse
 
drahdavid profile image
drahdavid

Thank you so much for the fix and the explanaition. CI=false npm run build worked for me.

Collapse
 
radidev profile image
Radi-dev

CI=false npm run build worked for me.
Thanks