Dev

React Uncaught ReferenceError: process is not defined

릭포드 2022. 3. 8. 16:58

갑자기 콘솔창에 Uncaught ReferenceError: process is not defined 에러가 뜨면서 hot reload는 되지만 ui가 얼어버린 것처럼 눌러도 상호작용이 되지 않는 문제가 발생했다.

 

검색해보니 유사한 사례가 좀 있었으며, 증상도 동일했다. (관련 토론)

 

v5 Regression react-error-overlay build - Uncaught ReferenceError: process is not defined · Issue #11771 · facebook/create-rea

I use following command to start: npm run start Then, whenever I save a file, I get the following "Uncaught ReferenceError: process is not defined" error in the browser console. VM27:2 Un...

github.com

 

위 토론에서는 비슷한 에러가 발생한다는 의견이 많고 실질적인 해결법은 딱히 없어서, 스택오버플로우 글을 읽어보았다. 

답변이 여러개 있었지만 내가 적용해서 해결된 해결 방법은 아래와 같았다.

// package.json

"resolutions": {
    "react-error-overlay": "6.0.9"
},

"scripts":{
    "preinstall": "npx npm-force-resolutions",
    ....
},

"devDependencies":{
    "react-error-overlay": "6.0.9",
...
}

package.json을 위와 같이 수정하거나 추가하고 npm i를 실행 한 결과 콘솔창에 뜨던 Uncaught ReferenceError: process is not defined 에러가 사라졌으며, ui가 얼어버리는 현상도 해결되었다.