1

I try running npx react-native init AwesomeProject for Create a new project. I have tested it before, but it created the project without error, but it doesn't work anymore. I had to reinstall nodejs.

Node.js v17.7.1

/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:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975: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

Node.js v17.7.1


4
  • 1
    You might have react-native-cli installed locally, which could cause issues as mentioned here. Try uninstalling react-native-cli using command npm uninstall -g react-native-cli and see if that resolves your issue Commented Aug 26, 2022 at 20:34
  • @sushrut619 I don't have react-native-cli installed, when I type react-native-cli -v , there is nothing, but when I type react-native -v : react-native-cli: 2.0.1 react-native: n/a - not inside a React Native project directory Commented Aug 27, 2022 at 15:26
  • CLI is command line interface. When you type react-native -v you are using the react-native-cli. It says in the output the version as 2.0.1. Have you tried uninstalling it globally using the command in my previous comment? What errors do you get when you try to init project after uninstalling react-native-cli ? Commented Aug 28, 2022 at 21:34
  • Does this answer your question? TypeError: cli.init is not a function for react native Commented Sep 14, 2022 at 9:27

2 Answers 2

1

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.

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

Comments

0

Check for the react-native present:

yarn global list

npm -g list

Uninstall the react-native & react-native-cli:

yarn global remove react-native

yarn global remove react-native-cli

npm uninstall -g react-native

npm uninstall -g react-native-cli

Check and confirm the react-native was uninstalled:

yarn global list

npm -g list

Install the react-native & react-native-cli:

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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.