Front-End/React Native
[React Native] Error: Requiring module "node_modules\react-native-reanimated\src\index.ts” 에러 해결법
현기
2022. 12. 7. 18:03
Drawer Navigation을 설치하다가
다음과 같은 에러가 발생했습니다.
ERROR Error: Requiring module "node_modules\react-native-reanimated\src\index.ts", which threw an exception: Error: Failed to initialize react-native-reanimated library, make sure you followed installation steps here: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/
1) Make sure reanimated's babel plugin is installed in your babel.config.js (you should have 'react-native-reanimated/plugin' listed there - also see the
above link for details)
2) Make sure you reset build cache after updating the config, run: yarn start --reset-cache
ERROR 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.
ERROR 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.
✔ 에러 메시지를 잘 보면 정답이 있습니다.
제가 실수로 네비게이션에 필요한 모든 패키지를
Install 하지 않아서 발생한 에러였습니다.
또한 bable.config.js 파일의 수정이 필요합니다.
📝 해결법
https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/
✔ 해당 사이트에 해결 방법이 제시되어 있습니다. 😀
⦁ 해결
//1. 터미널에 입력
yarn add react-native-reanimated
//2. babel.config.js 파일 수정
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
'react-native-reanimated/plugin',
],
};
};
참고 문헌 : https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/