11

I recently installed react native cli globally. When i tried to start a project using react-native init projectname or npx react-native init projectname it started downloading packages and creating the project. After completion it gave this error

    cli.init(root, projectname);
      ^

typeerror: cli.init is not a function
    at run (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:302:7)
    at createproject (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:249:3)
    at init (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:200:5)
    at object.<anonymous> (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:153:7)
    at module._compile (node:internal/modules/cjs/loader:1105:14)
    at object.module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at module.load (node:internal/modules/cjs/loader:981:32)
    at function.module._load (node:internal/modules/cjs/loader:822:12)
    at function.executeuserentrypoint [as runmain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

What is causing this problem?

2

6 Answers 6

19

Probably you are have and using old react-native-cli, try to:

npm uninstall -g react-native-cli or yarn global remove react-native-cli

and then run npx react-native init projectname again.

Sign up to request clarification or add additional context in comments.

1 Comment

The key for me was understanding that I need to ditch react-native-cli completely, and just let the npx react-native do the work
8

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.

Comments

7

The quick way out is

npx react-native init ProjectName --version 0.68.2

Because that error is from the new version 0.69.0 You can use upgrade to 0.69.0 later.

But the longer route is below:

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 

1 Comment

As mentioned in the docs, it is recommended to remove existing global react-native-cli packages.
1

Just delete react native cli from globally and manually delete folder at: c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli

It is work for me perfectly.

Comments

0

remove react-native CLI globally (npm uninstall -g react-native-cli) and reinstall your app (npx react-native init app name)

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

Replacing npx react-native with npx react-native@latest solved it for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.