Netlify Deployment error Fix: 'Treating warnings as errors because process.env.CI=true'
Tags: javascript, netlify, react, webdev
Published: 2023-02-02 22:38:17

Netlify is a cloud platform in which software developers can easily host their websites and web applications and it gets deployed instantly.

In this article, I will share how to fix Treating warnings as errors because process.env.CI=true the error message I recently encountered while trying to deploy a React application I am currently working on as a personal project.

## The Problem:


I tried to deploy an application built using react and chose Netlify as the platform in which it was to be hosted. I chose the option to Import an existing project from a Git repository. Netlify displays the deployment log terminal when an application is being deployed and from this section, messages can be seen on the progress of the project being deployed. Upon getting the application deployed, these error messages were displayed as a report on the progress of the deployment.


![image of deployment log from netlify with an error message Treating warnings as errors because process.env.CI=true](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c2q41kmrqbkv68lgnmh3.png)

![image of deployment log from netlify with an error message of build.failed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4whn4o10bjzu9a6rd1rb.png)

The reason for this error is that Netlify automatically **sets the build environment variable** to `true`, in doing so certain features in an application that were previously seen as warnings (in the terminal in of a local environment) and did not alter the build of the application in a local environment will now be detected while in the new environment. By the default setting by Netlify, your application due to the library being used will interpret this environment variable `CI` being set to `true` that is, `CI=true` where CI stands for Continuous Integration and then **interprets warnings as errors** hence the warning: "*Treating warnings as errors because process.env.CI=true"* and this interrupts the deployment of the application.

### What are Environment Variables?

**Environment variables are values** that help in setting up and controlling the environment in which your application gets deployed to.

## The Solution:
To fix this error, the first step is to set the build command of your application.

* Navigate to the **Site Settings** of the application you intend to deploy.
    
* Under the **Build and Deploy** section select **Continuous Deployment** and scroll down to the **Build Settings** section, Click on Edit Settings.
    
* Set the **Build Command** to `CI= npm run build` .
    

The next step will be to set the environment variable, which controls the environment to which your application gets deployed, to do that follow these instructions:

* Under the **Build and Deploy** section, select **Environment.**
    
* Click on **Edit Variables** and in the **key input** type in `CI`, in the **value input** type in `false` .
    

This unsets Netlify's default environment setting from `CI=true` to `CI=false`, when this is set, warnings during continuous integration or deployment will no longer be seen as errors that can halt the deployment of the web application.

Following these instructions will result in a successful build and deployment of your application, just as it did for me. You will see these messages in the deployment logs:


![image of deployment log from Netlify with a success message Build command from Netlify app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ri0b1h4y8xz793bch6ik.png)


![image of deployment log from Netlify with a success message Netlify build complete which confirms the success of the application deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/al349pgdg937s98ybqyg.png)

Note: These settings can also be applied when deploying an application to Vercel.