Error Handling : Netlify -Treating warnings as errors ....

heyj·2022년 2월 16일
0

Issues

목록 보기
1/2

Netlify Deploy

배포 도중 에러가 발생했다.
Treating warnings as errors because process.env.CI = true.
Most CI services set it automatically.

원인은 Netlify Docs에서 찾아볼 수 있다.
https://docs.netlify.com/configure-builds/troubleshooting-tips/#build-fails-on-warning-message

1. 왜 발생했나?

CI(Continuouse Integration)환경에서 실행되는 것을 감지하면, 일부 라이브러리와 빌드툴은 warnings을 다른 방식으로 처리한다.

Netlify도 다른 CI tool이나 플랫폼처럼 CI를 제공하므로, 라이브러리들이 warning messages들을 errors로 처리해 빌드가 실패한다는 것.

2. 어떻게 처리해야 하나?

Netlify 공식문서에서는 build commned 앞에 CI='' 를 추가하면 된다고 설명한다.

CI='' npm run build

많은 블로그에 CI=false로 에러를 처리하라고 쓰여있는데, 공식문서는 false가 예상대로 동작하지 않을 수 있다고 말한다. 이유는 환경변수값들은 strings으로 처리되는데, 많은 라이브러리들이 비어져있지 않은 CI string값은 true로 해석하기 때문이라고 한다.

“False” isn’t always false.

Though it seems like the logical opposite of CI=true, 
setting CI=false may not work as expected. 
This is because environment variable values are processed as strings, 
and many libraries interpret any non-empty string value for CI as true.

3. 해결

build & deploy CD탭에서 build command를 수정해주면 된다.

0개의 댓글