React-Native install on Windows Machine not finding $PATH - android

I'm installing react-native first y installing react-native-cli
Based on the instructions at: https://facebook.github.io/react-native/docs/getting-started.html...
I installed Android Studio and then added the sdk path to my $PATH, so if I echo $PATH, the path
/c/Users/MyUser/AppData/Local/Android/Sdk/platform-tools
is included. Then I...
npm install -g react-native-cli
which resulted in
C:\Users\MyUser\AppData\Roaming\npm\react-native ->
C:\Users\MyUser\AppData\Roaming\npm\node_modules\react-native-cli\index.js
+ react-native-cli#2.0.1
updated 1 package in 2.303s
but it is still not finding react-native ...
react-native-cli --version
bash: react-native-cli: command not found
Why can't I find my react-native-install?

react-native-cli is not a command. With this npm i -g react-native-cli you can use the command -> react-native
you can now use react-native init "project"
then npm start

Related

the development server returned response error code 500 - react native - ./configs/main

I got this error when i tried to make hello-world sample:
react-native init hello_world
cd hello_world
react-native run-android
Even when I ran:
npm install -g react-native-git-upgrade
react-native-git-upgrade
I got same error on commend line console.
I've searched and tried many solutions but it doesn't seem to work:
Example:
* upgrade react-native
* using watchman watchman watch-del-all
* remove node_modules
* clean cache npm cache cleanor npm start -- --reset-cache
Operation: Window 8
react-native-cli: 2.0.1
react-native: 0.44.2 ( tried 0.47.1 too )
Android: Simulator Nexus5X
Thank you all in advance!
Delete babel-preset-react-native folder inside node_modules and then install older version 2.1.0 of this library with npm install babel-preset-react-native#2.1.0 --save-dev.
In case if someone is using react-native: 0.57.1 or the latest one,babel-preset-react-native has been replaced by metro-react-native-babel-preset. if you still get 500 error while connecting to the device do the below step and I guess things will be fine
npm add #babel/runtime
npm install
Downgrade the following:
react-native init Project
cd Project
npm uninstall react-native
npm install --save react-native#0.55.4
npm uninstall --save babel-preset-react-native
npm install --save babel-preset-react-native#4.0.0
react-native run-android
For me it's about the react native version. I just install the new version of react native "0.59.2" then i downgrade to previous version to "0.55.2", and everything works fine.

Can't install react-native-cli after following tutorial

Before reading and following the tutorial in NPM I installed the react-native-cli globally and it worked just fine
But in the tutorial it asks you to install sinopia
https://www.npmjs.com/package/react-native-cli
Then it gives you these instructions
react-native$ npm set registry http://localhost:4873/
react-native$ npm adduser --registry http://localhost:4873/
# Check that it worked:
react-native$ npm config list
react-native$ npm unpublish --force
react-native$ npm publish
react-native$ cd react-native-cli/
react-native-cli$ npm unpublish --force
react-native-cli$ npm publish
But the unpublish part gave me an error. the same for the 'publish' aprt.
(By the way, publish what?!)
Then it says to uninstall react-native-cli
npm uninstall -g react-native-cli
After that I couldn't reinstall react-native-cli.
It says the package is not available.
npm ERR! 404 no such package available : react-native-cli
npm ERR! 404
npm ERR! 404 'react-native-cli' is not in the npm registry.
What is this?! How can I fix it?
#edit
By the way, I don't understand why, in the Get Started tutorial it doesn't tell us how to install the react-native-cli nor gives us a link. It just states:
The React Native CLI #
Node.js comes with npm, which lets you install the React Native command line interface.
#edit2
I just managed to install react-native-cli by removing the 'registry' entry from npm config, installing it and adding Sinopia again.
I thought Sinopia worked as a proxy. If it is not found in local repository, it looks for it in NPMJS...
I even tried to install other things and I could (wdio, nodemon), I just got an error with react-native-cli.
It seems that something is wrong.
Seems like you on Windows
I don't think you need sinopia.
Tutorials was little improved on master branch of the docs: http://facebook.github.io/react-native/releases/next/docs/getting-started.html
In short:
Install node.js
Install react-native-cli: npm install react-native-cli
Install & setup Android SDK
Create & run project
react-native init AwesomeProject
cd AwesomeProject
react-native start
react-native run-android

How do I create a React Native project using Yarn?

I am running the following commands in the DOS console on a Windows 7 (64-bit) machine.
npm install -g yarn
yarn add global react-native
yarn add global react-native-cli
react-native init sample
After running react-native init sample, the console was closed.
The error log shows:
D:\Mobile>"$basedir/../../Users/pramaswamy/AppData/Local/Yarn/.global/node_modules/.bin/react-native.cmd" "$#"
D:\Mobile>exit $?
I think you're adding global dependencies wrong, and you shouldn't need to install react-native, globally or locally. react-native init will create a package.json with react-native listed as a dependency.
You should be able to install react-native-cli globally with yarn global add react-native-cli, not yarn add global react-native-cli.
Here yarn run android command will be used to run the react native app using yarn package manager, and yarn start will start the node JS server.
You should be fine with running the following:
npm install -g yarn
yarn global add react-native-cli
react-native init sample
yarn run android
yarn start
NEW SEP 2019,
now it's more simple, use node10 and expo: (easy way)
npm install -g expo-cli
*to create project:
expo init AwesomeProject
cd AwesomeProject
npm start
*install the app 'expo' on your phone, and scan the qr code for the project and you can start to view your app
more info:
https://facebook.github.io/react-native/docs/getting-started.html
UPDATE OCT 2018 Create React Native App (now discontinued) has been merged with Expo CLI
You can now use expo init to create your project. See Quick Start in
the Expo documentation for instructions on getting started using Expo
CLI.
Unfortunately, react-native-cli is outdated. Starting 13 March 2017, use create-react-native-app instead. Moreover, you shouldn't install Yarn with NPM. Instead, use one of the methods on the yarn installation page.
1. Install yarn
Via NPM. According to its installation docs, you shouldn't install yarn via npm, but if necessary, you can still install it with a pre-v5 version of npm.
UPDATE 2018 - OCTOBER
Node 8.12.0 and NPM 6.4.1 is already compatible with create-react-native-app. Really some minors previous versions too. You don't need more downgrade your npm.
On Ubuntu.
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
On macOS, use Homebrew or MacPorts.
brew install yarn
sudo port install yarn
2. Install the Create React Native App
yarn global add create-react-native-app
3. Update your shell environment
source ~/.bashrc
4. Create a React native project
create-react-native-app myreactproj
You got the order wrong. You should be
yarn add global react-native-cli
yarn add react-native
react-native init sample
Please You visit Bug
yarn global add react-native-cli
with
react-native --version
and I get "$basedir/../../Users/juvasquezg/AppData/Local/Yarn/config/global/node_modules/.bin/react-native.cmd" "$#"
the system cannot find the path specified
Go to C:\Program Files\nodejs and I saw:
react-native
react-native.cmd
react-native.cmd.cmd
The fix is to delete react-native.cmd and rename react-native.cmd.cmd to react-native.cmd
The Solution #1324 (comment)
You could also do
yarn dlx expo-cli
then:
expo init project_name
and follow the instructions
after finishing cd project_name and try
yarn web
It is now:
yarn dlx create-react-native-app
then follow the instructions.
cd project_name into the project folder and do:
yarn install
then try with:
yarn web
If you want to create app using yarn instead of npx;
yarn dlx react-native init ExampleApp this command will be helpful.
According to the react native documentation we should use npx react-native init AwesomeProject command
For more info about "yarn dlx": https://yarnpkg.com/cli/dlx
Yarn global is deprecated. If you run yarn global you will get an error.
Usage Error: The 'yarn global' commands have been removed in 2.x -
consider using 'yarn dlx' or a third-party plugin instead
But yarn dlx won't work like yarn global or npm install <module> --global

React native command not found

I am starting to install react native. I had successfully installed homebrew, nodejs , npm. but not able to install react native
First I had tried
npm install -g react-native-cli
gives me write warning:
Missing write access to /Users/project/.npm-packages/lib/node_modules/react-native-cli
After that I had tried
sudo npm install -g react-native-cli
/Users/project/.npm-packages/bin/react-native -> /Users/project/.npm-packages/lib/node_modules/react-native-cli/index.js
/Users/project/.npm-packages/lib
└── react-native-cli#1.0.0
Looks like install.
After that I tried
react-native init AwesomeProject
Error : react-native: command not found
What could be the problem
First of all, you have to install react native globally
npm install -g react-native-cli
then it will show you the path for the react native like the following
/Users/{yourUser}/.npm-packages/bin/react-native -> /Users/{yourUser}/.npm-packages/lib/node_modules/react-native-cli/index.js
Then you have to set the default path from the above result and execute the following command
export PATH="/Users/{yourUser}/.npm-packages/bin/:$PATH"
Then reload you session/env vairables
source ~/.bash_profile
It will work like charm!
Make sure that /usr/local/share/npm/bin is in your PATH to use binaries installed with npm
Add the following line to your ~/.bashrc
export PATH="/usr/local/share/npm/bin:$PATH"
Then reload your shell session and try that again
sudo yarn global add expo-cli
sudo yarn global add react-native-cli
You must use sudo here.
when you are using the latest version of node js and others related to react native
they updated to run react native app
npx react-native run-android
npx react-native run-ios
You can check Here

react-native: command not found

I am getting -bash: react-native: command not found error while creating a react-native project.
Below are the additional info
1. brew --version
homebrew 0.9.9
2 brew info watchman
watchman `enter code here`stable 4.50
/usr/local/Cellar/watchman/4.4.0
3. brew info flow
stable 0.24.1
/usr/local/Cellar/flow/0.24.1
4. brew info node
stable 6.1.0
/usr/local/Cellar/node/6.1.0
5. npm -version
3.8.6
6. echo $PATH
/Users/Ashok/.rbenv/shims:/Users/Ashok/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I tried the suggested steps from this link but I am still getting the same error.
I don't have any "npm" directory which they have specified in the solution
Ashoks-MacBook-Pro:share Ashok$ ls
aclocal doc info ruby-build zsh
autoconf emacs man systemtap
But I found npm file exists in the below location.
/usr/local/Cellar/node/6.1.0/etc/bash_completion.d
I uninstalled react-native and installed it again but I am still facing the same issue.
After adding right path to the PATH variable issue is resolved.
Below are the steps to find the right path.
1. Enter: npm install -g react-native-cli
output: /usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native ->/usr/local/Cellar/node/6.1.0/libexec/npm/lib/node_modules/react-native-cli/index.js/usr/local/Cellar/node/6.1.0/libexec/npm/lib
└── react-native-cli#0.2.0
from above output you can clearly see the path: /usr/local/Cellar/node/6.1.0/libexec/npm/bin/react-native
export PATH="/usr/local/Cellar/node/6.1.0/libexec/npm/bin:$PATH"
react-native init appName
cd appName
react-native run-ios
if you getting xcrun: error: unable to find utility "simctl" at this stage you can reslove using below steps
XCode -> Preferences -> Locations -> Command Line Tools -> Choose Xcode 7.2.1
You can find original solution from xcrun unable to find simctl
Thanks to #fbozo
That's It!!!
run this code
npm i -g react-native-cli
close your cmd and open it again
After continually running into this problem, and hitting this answer and not having it work..
Assuming you don't run npm as root/sudo (which you shouldn't do!) your npm modules will be installed in whatever you set your default directory to be.
Assuming you have followed those instructions, and your default directory is ~/.npm-global, then you need to add ~/.npm-global/bin to your path.
This is outlined in those instructions, but for me I added this to .bashrc:
export PATH=$PATH:$HOME/.npm-global/bin
Then restart your shell and it will work.
Try
npx react-native
if doesn't work install globally
npm i -g react-native-cli
If who have error , try it with sudo:
sudo npm install -g react-native-cli
If you're using yarn, you may have to run commands with yarn in front. Example:
yarn react-native info
I ran into this issue by being a bit silly. I use nvm to manage my different versions of node, and installed react-native into a version of node that was not my default. Upon opening a new shell, I lost my command. :) Switching back of course fixed things.
If for some strange reasons, the path to react-native is not in the PATH, you should take note where the react-native executable is installed. Generally, the issue with command not found is because they are not in PATH.
For example, I use nodenv and run npm install -g react-native
/Users/khoa/.nodenv/versions/10.10.0/bin/react-native -> /Users/khoa/.nodenv/versions/10.10.0/lib/node_modules/react-native/local-cli/wrong-react-native.js
So I need to add that to my PATH
export PATH=$HOME/.nodenv/versions/10.10.0/bin:$PATH
You can verify with echo $PATH
Or you can use npx to execute local npm modules, for example
npx react-native run-ios --simulator='iPhone X'
Install react-native globally by using the following command
npm i -g react-native-cli
Had the same issue but half of your approach didn't work for me .
i took the path the way you did :from the output of react-native-cli instal but then manually wrote in ect/pathes with:
sudo nano /etc/paths
at the end i've added the path from output then ctrl x and y to save .
Only this way worked but big thanks for the clue!
Install react-native-cli with npm install -g react-native-cli.
You may need to use sudo like sudo npm install -g react-native-cli
At first run this command on your terminal.
npm i -g react-native-cli
Then create your react-native project by this command.
React-native init Project name
then move to your project directory by cd command.
According to official documentation, the following command worked for me.
npx react-native run-android
Link is here
https://facebook.github.io/react-native/docs/getting-started
I was trying to run by "react-native run-android" command. make sure to have react-native cli installed globally!
In case anyone has this problem, I had a similar problem to qix, but more nuanced.
New shell terminals would default to a different version of node.
I would change my terminal to the node I wanted, but when the bundle script run, it ran in a new shell, and it got the default version which did not have react-native installed.
I used nvm alias default x.x.x so that new shells would inherit the default version I wanted.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install yarn
brew install node
brew install watchman
brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk8
npm install -g react-native-cli
Dears,
Please try : npm install -g react-native-cli
If you get an error like Cannot find module ‘npmlog’ you can install npm directly using this command. If the above command run successfully then no need to run this command
curl -0 -L https://npmjs.org/install.sh | sudo sh
#For_Ubuntu.
Best regards.
In cmd Administration mode,Run
npm install react-native-cli
This is really weird, on my side (macOS 10.14), i'm pretty sure my node and npm work but i kept getting command not found only for this particular package. I ended up doing the following:
Install react-native-debugger
Make sure you enabled remote JS debugging, docs
Run react-native-debugger
Run your RN app
You can now debug view hierarchy and see console logs in react-native-debugger
I already had react-native and react-native-cli installed and just had to run:
yarn install
I had this issue after ejecting from expo and forgot to delete the node_modules and reinstall by running yarn or npm install.
After I did that then run npx react-native run-android, it worked fine!
try using react-native --help and see what comes up. try curl
react native library recommendation:
If you get an error like Cannot find module 'npmlog', try installing npm directly: curl -0 -L https://npmjs.org/install.sh | sudo sh.
https://facebook.github.io/react-native/docs/getting-started.html
I did an npm update, runned into the same error but after do an npm install and re-build the app worked!

Categories

Resources