프로젝트를 생성할 폴더로 들어와 터미널에서 아래 코드를 입력하는데 TypeError가 발생하였다
npx react-native init projectName
found 0 vulnerabilities
/opt/homebrew/lib/node_modules/react-native-cli/index.js:302
cli.init(root, projectName);
^
TypeError: cli.init is not a function
at run (/opt/homebrew/lib/node_modules/react-native-cli/index.js:302:7)
at createProject (/opt/homebrew/lib/node_modules/react-native-cli/index.js:249:3)
at init (/opt/homebrew/lib/node_modules/react-native-cli/index.js:200:5)
at Object.<anonymous> (/opt/homebrew/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (node:internal/modules/cjs/loader:1267:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
at Module.load (node:internal/modules/cjs/loader:1125:32)
at Module._load (node:internal/modules/cjs/loader:965:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.1.0
해당 오류는 React Native의 버전이 맞지 않아 발생한 오류로, 낮은 버전으로 실행하면 정상 작동된다.
npx react-native init projectName --version 0.68.2
+24.06.13 추가
전역으로 설치된 CLI를 삭제해주기(전역 설치는 비추천, 프로젝트마다 npx로 init 하는걸 추천)
npm uninstall -g react-native-cli
'React Native' 카테고리의 다른 글
[React Native] 카카오톡 로그인 연동 (0) | 2024.06.12 |
---|---|
[React Native] m1 에서 React Native 개발환경 세팅 및 프로젝트 생성(2024 ver) (0) | 2024.06.11 |
[React Native] npx react-native run-ios 에러 (0) | 2023.05.19 |
[React Native] Xcode 에러 (0) | 2023.05.19 |