'When runing 'npm run build' I get an error that says "'CI' is not recognized"

I'm working on a project and when I try to run npm run build I get an error that says "'CI not recognized". I've been looking for an answer and I'm not able to find anything.

  1. This is what I get in gitbash:

     'CI' is not recognized as an internal or external command,
    operable program or batch file.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] prebuild: `CI=true react-scripts test --colors`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] prebuild script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\Juan Mireles\AppData\Roaming\npm-cache\_logs\2021-01-16T20_05_42_295Z-debug.log
    
  2. This is my package.json:

    {
      "name": "project",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "@testing-library/jest-dom": "^5.11.6",
        "@testing-library/react": "^11.2.2",
        "@testing-library/user-event": "^12.2.2",
        "enzyme": "^3.11.0",
        "enzyme-adapter-react-16": "^1.15.5",
        "enzyme-to-json": "^3.6.1",
        "react": "^17.0.1",
        "react-dom": "^17.0.1",
        "react-placeholder-image": "^0.1.8",
        "react-router-dom": "^5.2.0",
        "react-scripts": "4.0.1",
        "router": "^1.3.5",
        "serve": "^11.3.2",
        "web-vitals": "^0.2.4"
      },
      "scripts": {
        "start": "react-scripts start",
        "prebuild": "CI=true react-scripts test --colors",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject",
        "predeploy": "npm run build",
        "deploy": "vercel --prod"
      },
      "eslintConfig": {
        "extends": [
          "react-app",
          "react-app/jest"
        ]
      },
      "browserslist": {
        "production": [
          ">0.2%",
          "not dead",
          "not op_mini all"
        ],
        "development": [
          "last 1 chrome version",
          "last 1 firefox version",
          "last 1 safari version"
        ]
      }
    }
    


Solution 1:[1]

Change your build script to the following:

"build": "set CI=false && react-scripts build"

Solution 2:[2]

If you're running on Windows, you need to change your prebuild.

"prebuild": "set CI=true&react-scripts test --colors",

https://create-react-app.dev/docs/running-tests/#on-your-own-environment

Solution 3:[3]

I removed the "CI" and it helped.

( "build": "react-scripts build")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nCardot
Solution 2 Wes Glassmeyer
Solution 3 Andrian Yu