숨참고 개발다이브

[React Native/RN] 프로젝트 생성 시 android, ios 폴더 안보임 문제(feat. TypeError: cli.init is 본문

개발/React & React Native

[React Native/RN] 프로젝트 생성 시 android, ios 폴더 안보임 문제(feat. TypeError: cli.init is

사라 Sarah 2022. 10. 4. 13:33
728x90



오랜만에 RN 프로젝트를 생성했더니 갑자기 android, ios 폴더 및 기타 주요 파일들이 생성되지 않았다.
오류 메시지는 다음과 같았다.

TypeError: cli.init is not a function


검색해보니 stackoverflow에서는 폴더를 재생성할때 eject를 사용하라는 답변이 가장 많았다.

react-native eject

react-native link

하지만 내 프로젝트에서는 먹히지 않는 상황이었다.


해결방법

eject 동작 안되는 현상으로 다시 검색해보니 react-native 와 react-native-cli를 재설치하라는 답변을 발견했다.

yarn global remove react-native
yarn global remove react-native-cli
yarn global add react-native
yarn global add react-native-cli


이후 혹시나 모른 버전 이슈때문에 프로젝트의 react-native 버전도 낮추어 다시 프로젝트를 생성했다.

npx react-native init YourProjectName --version 0.68.2


이 두가지를 모두 진행하니 정상적으로 파일과 폴더들이 생성되는 걸 확인할 수 있었다.





참조
https://stackoverflow.com/questions/72768245/typeerror-cli-init-is-not-a-function-for-react-native

TypeError: cli.init is not a function for react native

while running npx react-native init appName in MacBook air M1 chip TypeError: cli.init is not a function at run (/opt/homebrew/lib/node_modules/react-native-cli/index.js:302:7) at createProject (/opt/

stackoverflow.com

300x250
Comments