본문 바로가기
개발로그/ReactNative

** BUILD FAILED ** Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). 해결( 캐쉬삭제 방법 정리)

by 그리너리디밸로퍼 2023. 1. 21.

 

    발생한 에러

    Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
            A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

     위 에러의 해결책으로 stactoverflow 에서는 빌드시 발생하는 캐쉬를 정리할 것을 추천했다. 겸사겸사해서 캐쉬 삭제하는 방법을 정리해봤다. 

     

     

    시도할 방법 1 (npm /yarn)

    npm 사용자라면

    npm start -- --reset-cache

    yran 사용자라면

    react-native start --reset-cache

     

    시도할 방법 2 (android )

    android 폴더로 이동 한 뒤 아래 명령어 실행한다. 

    ./gradlew clean

    또는 

    cd android && ./gradlew clean && cd ..

    또는 

    휴대폰 모양 아이콘 왼쪽에 있는 쥐모양 아이콘 클릭(Sync project with gradle files)

     

    위 방법은 아래의 경우에 실행하는 것이 필수적입니다. 

    • react-native run-android로 android emulator 실행 전
    • 상대방은 잘 빌드가 된다고 하는데 내 컴퓨터에서만 빌드가 잘 안되는 경우

    타인이 작업하던 프로젝트를 다운 받아서 실행하자 할 때 유용하고 필수적 입니다. RN 내의 Android SDK의 경로가 전 작업자의 컴퓨터의 절대 경로로 지정되어 있는 경우가 많기 때문에 에러가 뜹니다.

     

    시도할 방법 3 (IOS)

    XCODE 에서

    Xcode 상에서 Cmd + Shift + K 혹은 맨상단의 Product에서 clean

    또는 

     

    터미널에서 

    rm -rf ~/Library/Developer/Xcode/DerivedData 
    //빌드 시 생성된 자료들 초기화. 어디서 실행하든 상관없음

    위 두 방법은 빌드가 꼬이거나, 컴파일들에 문제가 생긴 경우 기존 빌드 결과 생성된 폴더들을 초기화 한다고 생각하시면 됩니다.

     

    POD 에서 

    pod install //ios폴더 안에서 실행해야함

    이 방법은 npm install 은 했지만 , pod install 을 누락한 경우 Xcode로 빌드 시에 ~.h 파일에서 문제가 생기게 됩니다. react-native run-ios로 simulator 실행 전에 꼭 pod install결과 초록색 명령어 들이 뜨면서 successful한지 확인해주세요.

     

    애증의 pod install 성공(초록색) 화면

     

    728x90

    댓글