TypeError: cli.init is not a function – Code Example

Total
0
Shares

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 –

npx react-native init MyProject