Hello,
When running the react-scripts build
on the CI, the build script does the following
Treating warnings as errors because process.env.CI = true.
This is due to this line of code.
I disagree with treating the CI differently during the build as it creates inconsistency between local environment and the CI. I pushed the code to github knowingly about the warnings, having the CI break from the warning I approved of pushing is rather unexpected to the user.
Hi! We've had a large discussion about this previously and decided that this is the best default behavior.
If you'd like to not use this behavior, simply set CI
to false
during your build
command, e.g. CI=false npm run build
.
hi @Timer! can you please provide a link to the discussion where it was decided to treat errors as warnings? Couldn't find it.
What about the other direction? What if I'd like to treat warnings as errors locally? Am I supposed to manually set the CI
environment variable?
I'd prefer the default is to always treat warnings as errors, regardless of the environment, and give people some way to opt out if they think they know what they're doing (such as @Bamieh).
I am wondering what else is it using the env var CI ... if you set it to false beside the error/warning behavior is something else affected by this env var?
@mhermosi to my knowledge the test script is affected. If CI is false then it goes into a watch mode which is something you do not want on a CI-server.
So how do we opt out from "treat errors as warnings" while not using a watcher in the tests? Am I missing something?
I think this is weird implementation as well. There should be a way to keep process.env.CI = true
but turn off warnings as errors.
Most helpful comment
Hi! We've had a large discussion about this previously and decided that this is the best default behavior.
If you'd like to not use this behavior, simply set
CI
tofalse
during yourbuild
command, e.g.CI=false npm run build
.