Raana Tashakori
Raana Tashakori

Reputation: 457

Why does cli.init fail when creating react-native project?

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


Upvotes: 1

Views: 935

Answers (2)

prabhu g
prabhu g

Reputation: 1

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

Upvotes: 0

mohamed benmoussa
mohamed benmoussa

Reputation: 31

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.

Upvotes: 1

Related Questions