반응 네이티브 초기화 프로젝트 오류 TypeError: cli.init는 함수가 아닙니다.

질문

$ react-native init AwesomeProject
...
/usr/local/lib/node_modules/react-native-cli/index.js:302
  cli.init(root, projectName);
      ^

TypeError: cli.init is not a function
    at run (/usr/local/lib/node_modules/react-native-cli/index.js:302:7)
    at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3)
    at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:153:7)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

해결책

설치된 반응 네이티브 라이브러리를 보려면 npm -g list를 사용하십시오.

$ npm -g list
/usr/local/lib
├── 。。。
├── [email protected]
├── 。。。

React-native-cli 라이브러리 제거

npm uninstall -g react-native-cli
npm uninstall -g react-native  // 如果有,也一起卸载了

npx 반응 네이티브 초기화를 사용하여 프로젝트를 다시 초기화하세요.

npx react-native init AwesomeProject

Guess you like

Origin blog.csdn.net/kongxx/article/details/132678796