본문 바로가기
*오류해결

cli.init is not a function 오류

by yun5o 2023. 2. 12.

cli로 프로젝트를 생성하면 아래와 같은 오류가 발생합니다. (npx react-native init 프로젝트명 명령어 실행 후 오류)

TypeError: cli.init is not a function

Installing react-native...
Consider installing yarn to make this faster: https://yarnpkg.com
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0

added 652 packages, and audited 653 packages in 7s

33 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
C:\Users\YUN\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302
  cli.init(root, projectName);
      ^

TypeError: cli.init is not a function
    at run (C:\Users\YUN\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302:7)
    at createProject (C:\Users\YUN\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3)
    at init (C:\Users\YUN\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5)
    at Object.<anonymous> (C:\Users\YUN\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

 

해당 오류는 버전이 맞지않아 발생한 오류입니다.

react-native 버전을 낮춰 프로젝트를 실행하면 정상적으로 생성됩니다.

npx react-native init 프로젝트명 --version 0.68.2

 

댓글