Treating warnings as errors because process.env.CI = true.
Roby Cigar

Roby Cigar @robycigar

Joined:
Oct 6, 2020

Treating warnings as errors because process.env.CI = true.

Publish Date: May 12 '21
7 6

This error happened everytime I deploy my react code to vercel. I solved this error by put this on scripts.
put this thing on your package.json, when you see

CI=false npm run build
Enter fullscreen mode Exit fullscreen mode

Don't put quotation as a string on env variable -vercel

scripts: {
  "build": "GENERATE_SOURCEMAP=false react-scripts build"
}
Enter fullscreen mode Exit fullscreen mode

There is also a built-in environment variable called NODE_ENV. You can read it from process.env.NODE_ENV. When you run npm start, it is always equal to 'development', when you run npm test it is always equal to 'test', and when you run npm run build to make a production bundle, it is always equal to 'production'. You cannot override NODE_ENV manually. This prevents developers from accidentally deploying a slow development build to production.

Comments 6 total

  • Rafael Lima
    Rafael LimaAug 23, 2021

    You can create an env varaible on Vercel called CI and set it to false, that works too

  • `Nazir Abubakar
    `Nazir AbubakarDec 11, 2021

    I don't completely understand what needs to be done to bypass this error.

    • Phoebe
      PhoebeDec 16, 2021

      agree with you. The author should give a bit more of context.

      What he meant is that in your package.json, under "script" > "build". Whatever command build you have, you should add "CI = false" to override the default value which is "CI=TRUE".

      For his example:
      "build": "npm run build"
      New line will be "build": "CI=false npm run build".

      My case I have to write like this "build" : "CI=false && craco build". I used Typescript. Not sure if the && symbol needed or not. I dont bother to test actually :)

      But if you only change in package.json and deploy vercel, Preview will be successful (Active) but Production still fails.
      So, final solution to solve for both Preview and Production is to add environment variable in Project Settings > Environment Variables in Vercel.

      • `Nazir Abubakar
        `Nazir AbubakarDec 16, 2021

        Thank you, for this.

      • Magima Felix O
        Magima Felix OJan 6, 2022

        you guys rock CI=false is the best fix
        can also add it directly in vercel directly without adding it to a .env file of your project :)

  • Rajarshi Agarwal
    Rajarshi AgarwalJan 31, 2022

    just go to settings -> environment variables ->and do the following
    Name -> CI
    Value -> False
    and click Add


    After this when u deploy, u wont get the problem again

Add comment