React Native 빌드 에러 (2)
Mac OS 를 쓰면서 마주한 React Native 빌드 에러에 대해 정리한다.
M1 프로세서를 사용 중인데 이것이 원인 중 하나인지는 명확하지 않다.
iOS
1. (빌드 에러) node: No such file or directory
nvm 을 사용하고 있는 사람이라면, 아래 명령어 실행으로 해결할 수 있다.
sudo ln -s "$(which node)" /usr/local/bin/node(출처)
2. (빌드 에러) Something went wrong. Please verify if generated JS bundle is correct.
번들 명령어를 통해 main.jsbundle 파일을 직접 만들고, Xcode 에서 프로젝트를 연 뒤 해당 파일을 드래그앤드랍으로 넣어주면 된다.
yarn react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/main.jsbundle만약 이미 main.jsbundle 파일이 Xcode 상에 추가되어 있다면 기존 파일(레퍼런스)은 삭제 하고 새로 생성한 파일을 추가해보자.
(출처)
3. (pod install 에러) CocoaPods could not find compatible versions for pod "Firebase/Analytics"
비단 Firebase/Analytics 만의 문제가 아니라, 라이브러리를 추가/버전업 할 때 마주할 수 있는 에러로 보인다.
일단은 ios/Podfile.lock 파일을 삭제한 뒤 아래 명령어로 해결했다.
pod install --repo-update안드로이드
1. (빌드 에러) An exception has occurred in the compiler (1.8.0_292)
에러 전문은 아래와 같다.
An exception has occurred in the compiler (1.8.0_292). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
react-native-fierbase/messaging 을 설치한 뒤 발생했다. 해당 라이브러리에 직접적인 문제가 있다기보다는, 안드로이드 SDK 버전이 올라가면서 필요한 openjdk 버전도 올라간 것 같다.
openjdk 버전을 11로 올려주면 해결된다. 아래는 MacOS 에서 openjdk11 을 설치하는 명령어다.
brew tap adoptopenjdk/openjdk
brew install --cask adoptopenjdk112. (Metro 에러) jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
안드로이드 개발 빌드에서 느닷없이 hot reloading 이 동작하지 않는 현상이 발생했다. Metro 쪽을 보니 아래와 같은 에러 메시지가 찍혀 있었다.
jest-haste-map: Watchman crawl failed. Retrying once with node crawler. Usually this happens when watchman isn't running. Create an empty
.watchmanconfigfile in your project's root folder or initialize a git or hg repository in your project. Error: Watchman error: watchman::QueryExecError: query failed: synchronization failed: syncToNow: timed out waiting for cookie file to be observed by watcher within 60000 milliseconds: Operation timed out. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.
구글링을 하다가 나와 같은 증상의 이슈를 찾았다. 그래서 코멘트에 있는 답변들을 시도해봤는데, 안 되고 안 되고 안 되다가 결국에는 해결되었다. 내가 진행한 과정은 아래와 같다.
brew reinstall watchmanwatch-del-all && yarn cache clean && react-native start --reset-cache.watchmanconfig삭제 후 새로 파일을 만든 뒤 기존과 동일한 내용을 넣음- 재부팅
마지막 에 재부팅을 하고 나서야 해결되었다. 이게 저 위의 네 과정을 다 거쳐야 하는 것인지, 저 중 하나만 하면 되는 건지, 몇 개만 조합하면 되는 건지, 그건 불명이다.