Netlify Deploy Treating Warnings as Errors

Netlify Deploy Treating Warnings as Errors

If you’re like me, you were minding your own business and deploying your latest feature to staging. And if you’re even more like me, you’re not in the habit or monitoring every single deploy but your pipeline just works.

Until it doesn’t.

This morning’s deploy came to a grinding halt with the following error:

Treating warnings as errors because process.env.CI = true.
Brooklyn 99 — Oh, cool

Luckily, for as daunting as the error may seem, there’s a pretty straight forward fix to it.

process.env.CI = true

Let’s set that to and carry on like the wayward children we are.

How to Fix

There are two ways this error may be fixed and it depends on your build setup.

Netlify.toml

If the build command for your project is handled in the file, then the fix can be made there as well by manually setting to false inside of our build command.

Note, that the file takes precedence over the build settings stored in Netlify.

[build]
command = "CI=false && yarn build"
publish = "build"

Netlify Build Settings

If there is not a file in the project, the build settings can be handled directly in Netlify. By navigating to SettingsBuild & DeployContinuous Deployment — Build Settings, you can update the build command to set for each build.

Netlify build settings
Netlify build settings

One caveat, in the event that adding to the build command still doesn’t work, trying setting because older versions of behave differently and may require an empty string. More information can be found in this thread: https://github.community/t/treating-warnings-as-errors-because-process-env-ci-true/18032

I live my life one hot chocolate at a time.