Typeerror: Cli. Init Is Not a Function for React Native

While running npx react-native init appName in MacBook air M1 chip

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:1112:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
at Module._load (node:internal/modules/cjs/loader:834:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
1

17 Answers

install new react-native global

npm uninstall -g react-native-cli

install new react-native global

npm install -g react-native-cli

npm install -g react-native

and create project again

npx react-native init AwesomeProject
4

Need to clean global environments with following commands:

yarn global remove react-native

yarn global remove react-native-cli

npm uninstall -g react-native

npm uninstall -g react-native-cli

check that nothing related to react-native presents in these lists:

yarn global list

npm -g list

install new react-native global

npm install -g react-native-cli
npm install -g react-native

then you can run:

npx react-native init ProjectName 
3

This happened because you have an old version of react native, So you need to remove the react native version globally and install it again.

Steps to fix your problem:

if you use Yarn:

First Step: Check the Global installation list:

yarn global list

if you found react-native and react-native-cli so go to the next step and remove them globally

Second Step:

yarn global remove react-native
yarn global remove react-native-cli

Third Step: Install them again

yarn global add react-native
yarn global add react-native-cli

if you use NPM:

First Step: Check the Global installation list:

npm -g list

if you found react-native and react-native-cli so go to the next step and remove them globally

Second Step:

npm uninstall -g react-native
npm uninstall -g react-native-cli

Third Step: Install them again

npm install -g react-native
npm install -g react-native-cli

Note: Delete the old project you create, then create it again. Every thing will go fine.

That is error is from the new version 0.69.0 You can use npx react-native init ProjectName --version 0.68.2 and then upgrade to v 0.69 later.

2

I think latest stable version is 0.68.2, so create project at this level using command given below

npx react-native init ProjectName --version 0.68.2

1

If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues:

npm uninstall -g react-native-cli @react-native-community/cli

Link Here

0

Should run:

yarn global list or npm global list

And uninstall all cli's of the react-native in list, after run:

yarn global add @react-native-community/cli

If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues:

npm uninstall -g react-native-cli @react-native-community/cli

React Native has a built-in command line interface, which you can use to generate a new project. You can access it without installing anything globally using npx, which ships with Node.js. Let's create a new React Native project called "AwesomeProject":

npx react-native@latest init AwesomeProject

This is not necessary if you are integrating React Native into an existing application, if you "ejected" from Expo, or if you're adding Android support to an existing React Native project (see Integration with Existing Apps). You can also use a third-party CLI to init your React Native app, such as Ignite CLI.

1

Do-> yarn global remove react-native-cli && npm uninstall -g react-native-cli

Then-> yarn global add @react-native-community/cli or npm install -g react-native-cli

I was able to clear the issue by uninstalling the cli and only installing react-native

npm uninstall -g react-native-cli
npm install -g react-native

then

react-native init ProjectName

I am using

react-native -v
10.1.3

If you have already installed react native globally, uninstall it by: npm uninstall -g react-native-cli

Then install it again by: npm install -g react-native-cli

Then you can create your new project by the following command: npx react-native init <project_name>

yarn add react-native --exact

I re-installed react native with --exact and this fixed my problem

remove react native cli using this command

npm install -g react-native-cli

no need for it now as.

React Native has a built-in command line interface, which you can use to generate a new project.

Check reactnative.dev

1

if you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues. You can run the following command:

npm uninstall -g react-native-cli @react-native-community/cli

or

yarn global remove react-native-cli @react-native-community/cli

Follow the Reference:

I tried every solution above mentioned none of them didn't worked actually except this(npx react-native init ProjectName --version 0.68.2)

But finally i fixed my issue by deleting node modules from my user folder .

then now run :- npx react-native@latest init projectname

npx react-native init AwesomeProject --version 0.68.2 solved my problem

1

Try with this latest command.

npx react-native@latest init ProjectName

Worked for me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest