Why react-native-cli giving errors? - react-native

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?

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.

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.

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

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.

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

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

Related

npx react-native init , not creating project

when I run new project command it shows me an error
npx react-native init AwesomProject
npm ERR! Could not install from "computer\AppData\Roaming\npm-cache_npx\15660" as it does not contain a package.json file.
try this : npm uninstall -g react-native-cli #react-native-community/cli
or
use Expo

'cb.apply is not a function' error running 'npx react-native init'

I want to learn React Native, so i read documents in Offical Site and I install some softwares. I installed JDK, Android Studio, NodeJs, Watchman..
At the least, When i use this command:
npx react-native init AwesomeProject
I got error:
npm ERR! cb.apply is not a function
I tried to graceful, but it didn't work.
npm install graceful-fs --save-dev
So what should I do ?
I'm using Linux Mint 18.
you most install npm:
install npm
than install react-native :
npm install -g
react-native-cli && npm install -g react-native (admin or sudo)
then for create project use:
react-native init MyProject
than go to project folder with :
cd Myproject
and finally use this for run project:
react-native run-ios or run-android

Cannot find module 'asap/raw'

i have started a new react-native project and after that i installed react-native-maps i can't run react-native run-android because the terminal displays the following error:
module.js:550
throw err;
^
Error: Cannot find module 'asap/raw'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/valentino/Scrivania/lolo/node_modules/promise/lib/core.js:3:12)
at Module._compile (module.js:653:30)
at Module._compile (/home/valentino/Scrivania/lolo/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (module.js:664:10)
at Object.newLoader [as .js] (/home/valentino/Scrivania/lolo/node_modules/pirates/lib/index.js:88:7)
at Module.load (module.js:566:32)
The message is shown if i install react-native-maps, this is the command with i have built the project with:
react-native init appName
cd appName
npm install react-native-maps --save
react-native run-android
How I can resolve this problem?
Am I doing something wrong?
Thanks for the help.
Running npm install in your project directory usually works.
(What it does is that it installs all the dependencies in the local node_modules folder that may have been downloaded when you installed that one package.)
Running npm install did not solve the problem for me.
I ran npm install -g asap to install asap and then the error went away.
The react-native init command creates a project which uses yarn by default since 0.57 (has yarn.lock). I had the same error when I installed a plugin by npm install, so the conclusion is that you can't use both package manager for the same project at the same time (yarn and npm). So:
Use yarn add instead of npm install.
Or if you don't want to use yarn, then "switch" to npm by running npm install first (after this you can delete yarn.lock and you must always use npm from this point instead of yarn).
Deleting node_modules and reinstalling didn't fix but doing npm install asap in the project directory fixed my issue.

npm error while creating react native app

I used following command
npm install -g create-react-native-app
create-react-native-app AwesomeProject
cd AwesomeProject
npm start
but it showing me following error.
anyone can help?
Update your:
Node version to the latest
npm (npm install -g npm#latest)
yarn (npm install --g yarn).
And try again to run create-react-native-app AwesomeProject

Command "react-native" can not run after installed react-native-drawer

I inited React native project by:
react-native init MyShop
In MyShop folder, I install "react-native-drawer":
npm install --save react-native-drawer
After install, I run project by:
react-native run-android
And get error "Command run-android unrecognized. Make sure that you have run npm install and that you are inside a react-native project."
I checked react-native by command line
react-native -v
And get info:
react-native-cli: 2.0.1
react-native: n/a - not inside a React Native project directory
It seems react-native lib has been removed after installed react-native-drawer.
My npm version:
E:\2.Projects\My\MyShop>npm -v
5.0.4
My node version:
E:\2.Projects\My\MyShop>node -v
v8.1.2
Please help me re-procedure and fix it. Thank you!
I found out solution for this issue!
I update npm to latest version: 5.1.0.
Uninstall react-native-cli:
npm uninstall -g react-native-cli
Next, reinstall react-native-cli:
npm install -g react-native-cli
My issue has been fixed.
Install react-native without -cli
npm install -g react-native
It will fix the issue......Hopefully....coz