最近在玩React-Native的时候,创建项目出现cli.ini错误,找了好久才知道这个方法,分享给大家。
TypeError: cli.init is not a function – Code Example
From V0.69, React-Native stopped supporting global installation of react-native-cli
. If you try to run npx react-native init MyProject
command, it will throw TypeError: cli.init is not a function error. To resolve this issue, you need to initialize your project with specific react-native version.
Solution with Code Example
npx react-native init MyProject --version 0.68.2
This will initialize your project on version 0.68.2
.
If you want to use the latest cli version, then first you will need to uninstall any globally installed react-native
or react-native-cli
using this –
执行下面的四个命令:
yarn global remove react-native
yarn global remove react-native-cli
npm uninstall -g react-native
npm uninstall -g react-native-cli
Then, there is no need to install anything. Just use npx
like this –
无需再安装React,直接执行下面的命令创建项目:
npx react-native init MyProject
- 新项目 React-Native TypeError function 错误新项目react-native typeerror function liboptions typeerror function错误 getusermedia typeerror navigator function searchlist typeerror function slice javascript typeerror uncaught function defineconfig typeerror function not typeerror classname function taro3 typeerror function track vue3 typeerror function gitbook问题 typeerror function weekday clone