Noob here,
Im trying to run android emulator installed for my reactnative app to test on vscode online on azure linux machine and getting the follow error:
Specify configs in the ini-formatted file:
/home/vsonline/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
when I run npm start-android-emulator I get the error.
Please any help. I am trying to run react-native code without installing android studio
you should use npx or yarn like this npx start-android-emulator or yarn start-android-emulator
Please note I have read the documentation and I'm referencing the point where the error happens as well as the steps I have taken. Please don't advice me to follow the instructions that I have already indicated I have followed.
After following the documentation of React Native to the best of my ability, I have been unable to get React Native to run. I have installed jdk, node, and Android Studio as instructed (using Chocolatey and links). The Android Emulator runs from Android Studio. I'm using npm version 6.1.0, node version 8.4.0, jdk 8, Android Studio 3.1.3. The error I get after react-native init AwesomeProject is SyntaxError: Unexpected token import. What did I do wrong? How can I fix this? Running react-native run-android also gives the same error.
To be clear, I'm in the proper directory. ANDROID_HOME is set to the proper sdk folder. There is a heading, Running your React Native application, and running the first command leaves me with the error, but I don't get an error before that point.
install npm
install react native cli => npm install -g
react-native-cli && npm install -g react-native (admin or sudo)
react-native init MyProject
cd Myproject
react-native run-ios or run-android
Update node to the latest version.
npm install -g react-native-cli.
npx react-native init newProject.
Since you install react native globally you don't need to use npx packages anymore just try
react-native init newProject
Assuming that you have Node 14 LTS or greater installed, you can use npm to install the Expo CLI command line utility:
npm install -g expo-cli
Then run the following commands to create a new React Native project called "AwesomeProject":
expo init AwesomeProject
cd AwesomeProject
npm start
Source: React Native Environment Setup
I just started learning react native. I am following this tutorial to set up my environment: https://www.raywenderlich.com/178012/react-native-tutorial-building-android-apps-javascript
Everything seems okay until the point where I have to run 'react-native run-android'. I get the error below:
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
Could not determine java version from '9.0.4'.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
I have both JAVA 8 and 9 installed but I am pointing to Java 8. This is what $JAVA_HOME returns when I echo:
"/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java"
Note, I have an emulator running too.
Have you tried to do what s on this link below as-well:
https://facebook.github.io/react-native/docs/getting-started.html
This page will help you install and build your first React Native app.
The commands:
$npm install -g create-react-native-app
$create-react-native-app AwesomeProject
$cd AwesomeProject
$npm start
(I also tried a Youtube video regarding how to start and run a project on Ubuntu : https://www.youtube.com/watch?v=OZ5nCNOzflM )
I did it myself and for me it worked, at least for what I showed above.
This part is about building projects with React Native:
https://facebook.github.io/react-native/docs/getting-started.html
Commands :
$npm install -g react-native-cli
Install JS needed:
Add the following lines to your $HOME/.bash_profile config file:
export JAVASCRIPT_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Create project:
$react-native init AwesomeProject
Run:
$cd AwesomeProject
$react-native run-android
Let me know if I was of any help or not.
I am also trying to integrate Boilerplate for Android using React Native on a Linux Platform (Ubuntu) and I still didn t find a solution to do that, except what I described above.
Good Luck :)
I've installed react-native-cli globally:
npm install -g react-native-cli
Then run:
react-native init AwesomeProject
cd AwesomeProject
I got the following structure:
-- AwesomeProject
---- node_modules
------ react-native
When I run react-native run-android I get an error:
Command run-android unrecognized. Did you mean to run this inside a react-native project?
When I run react-native start I get the same.
react-native -v
prints:
react-native-cli: 0.2.0
react-native: n/a - not inside a React Native project directory
What I'm doing wrong?
the answer is easy nad it is not because of any bug at all.
make sure you are in correct directory
if in current directory there is not any react native app ,it gives you this error
What caused this for me was running npm install --save [package] when actually the system has previously been using yarn instead of npm.
To solve this I just deleted the node_modules folder and ran: yarn install and after that react-native run-ios (or android) works fine.
(This is a duplicate of React Native: Command `run-ios` unrecognized)
I just ran "yarn" with no arguments and it fixed it.
Please try this command:
npm install --save react-native
The problem was that I terminated init command because it looked like hanged without errors (even 24 hours later). To fix this I updated nodejs and npm to newer versions. Once I have done it react-native init was executed properly and there is no more problem with react-native run-android.
react-native run-android is unrecognized
Make sure that you have installed npm or use
in your project directory
npm install
you have to update your npm.
To do that
npm install npm#latest -g
try "yarn install".
It will install the missing files in node_modules
It worked for me
This can be caused by a couple of issues.
!!! Before trying each solution remember to open a new terminal since you might have old paths sources from your .bashrc file. !!!
You did not install the contents of the project. In order to solve this you have to install the node_modules by typing:
npm install or yarn install
You are coming back to a previously installed project after doing some funny things with your react-native installation and global configurations. (Upgrading the library, upgrading node doing something with globally installed node_modules).
You should clean all your caches and project modules
Here you can find a command to do all these things in one line (remember to replace npm with yarn accordingly):
https://gist.github.com/jarretmoses/c2e4786fd342b3444f3bc6beff32098d
Your global installation of react-native or react-native-cli is broken. In this case simply reinstall your libraries globally.
npm: npm install -g react-native && npm install -g #react-native-community/cli
yarn: yarn global add react-native && yarn global add #react-native-community/cli
I think the command you are looking for is react-native run-android.
cd into your project and run this command where all you js files are present and not in the android folder.
It will run a package manager, do not close that. Also you need to have an emulator or a device connected to your computer with usb debugging enabled.
Hope the answer helped
npx react-native run-android
Use of npx will pick local npm node_modules directory
Do npm install then run react-native run-android
Make sure you go into the directory having package.json
If you have deleted nodemodules try "npm install".
And don't forget the "init" in "react-native init MyApp". "init"
initializes the package.json.
Step 01 : Make sure that you are in right directory
Step 02 : npm install run this command
Step 03 : npm audit fix run this to fix issues
Try deleting node_modules folder and then run the commands again
You can solve this by yarn or npx:
yarn react-native run-android
npx react-native run-android
Everything has already tried like me? Then try again once "Yarn install after deleting node_modules". It worked for me.
I did everything correct while setting up, but was unable to run the android code. Just make sure while running the command react-native run-android that, you are inside the AwesomeProject folder created by the react-native init AwesomeProject command.
The folder by default for my PC was under C:\Windows\system32\AwesomeProject in Windows.
Hope it helped for the first timers :)
You need to update the project with the latest version of react-native. Just run this command.
npm install --save react-native#latest
If you guys have latest react native version and facing this error
"UNRECOGNIZED COMMAND run-android".
then run follow these steps it will definitely help you.
Step: 1 -> create a new file "react-native.config.js" in the project root directory.
Step : 2 -> Inside "package.json" you have "assets" array inside "rnpm" object cut these assets from this and paste in your "react-native.config.js".
i-e:
module.exports = {
assets: ['./assets/fonts'],
}
Step : 3 -> Remove "rnpm" object from "package.json".
Step : 4 -> Replace your "scripts" with below mentioned "scripts" inside "package.json"
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"android:prod": "npx react-native run-android --variant=release",
"ios:prod": "react-native run-ios --configuration Release"
}
That's it
Happy Hacking..............
Uninstall react-native from global
$ npm uninstall -g react-native
Then
Install react-native to global
$ npm install -g react-native-cli
That worked for me
react-native run-android
start [options] starts the webserver
run-ios [options] builds your app and starts it on iOS simulator
run-android [options] builds your app and starts it on a connected Android emulator or device
new-library [options] generates a native library bridge
bundle [options] builds the javascript bundle for offline use
unbundle [options] builds javascript as "unbundle" for offline use
eject [options] Re-create the iOS and Android folders and native code
link [options] [packageName] links all native dependencies (updates native build files)
unlink [options] <packageName> unlink native dependency
install [options] <packageName> install and link native dependencies
uninstall [options] <packageName> uninstall and unlink native dependencies
upgrade [options] upgrade your app's template files to the latest version; run this after updating the react-native version in your package.json and running npm install
log-android [options] starts adb logcat
log-ios [options] starts iOS device syslog tail
dependencies [options] lists dependencies
info [options] Get relevant version info about OS, toolchain and libraries
They have made some unnoticeable changes. For instance run-android(now) run android(before).
Try to delete "package-lock.json" and re-run "npm install", then try your command, It should work
I got this error because I had parenthesis in the path "(" and ")". Possibly this error is thrown for other special characters as well.
Ensure you run the command in the projects' terminal, preferably the Android IDE. Run the adb devices to know your active devices as well
If your package.json file is containing any comment then this error is comes. So remove all comments from package.json and then run command it will work.
Also try to run command npm install --save then it will log if other error there. If any others error also there, then first fix it and then run command it will work.
In Android Studio click in Tools -> SDK Manager -> in System Settings click in Android SDK -> choose tab SDK Tools, then enable Android SDK command line tools (lasted).
It work for me!
Open your React Native Project Root Directory and locate android -> app -> build -> intermediates -> signing_config -> debug -> out -> signing-config.json
Delete signing-config.json file
And rebuild your application.
react-native run-android
First thing you need to delete node_mouldes and package.lock.json and do yarn install after that if you're using Windows OS you need to use PowerShell not git bash and write this command "react-native run-android"
Install npm again to latest
react-native init project_name
cd project_name
open android studio the same android folder inside your project_name
react_native run_android
will work now
for the last time your project was working fine and now you got this error suddenly and you have Node modules already installed then just trynpm install --save react-native
this work for me
When starting android project with React-Native it is giving this error:
React-Native Command run-android unrecognized.Did you mean to run this inside a react-native project?
You can try to do npm install before react-native run-android
First we have to install react-native then upgrade packages if you need and run android.
npm install --save react-native#latest
react-native upgrade
react-native run-android
A lot of developers fail to mention the crucial point,that certain commands require you to be a particular directory. In this case, to "react-native run-android", you have to be in your project directory!
Command run-android unrecognized. Make sure that you have run npm install and that you are inside a react-native project.
I faced this issue, the problem is we need to navigate to or project folder.
example: I created the project in "MyApps" with app name "DemoApp" in D drive
the command line root should be like this:
D:\MyApps\DemoApp>react-native run-android
now it will run with out any issue.
The problem is your android related info is presents inside the app not t=in the main directory.
I was facing the same problem and the above solutions did not work. Try using:
yarn add react-native-cli
First of all please see if devices/emulator is attached and working by following command
adb devices
there should be some devices showing connected
it is better to restart/reconnect you emulator/device and then try to run application again
if not working you can also try
npm install
You need to make sure that you are inside the project like cd AwesomeProject and do npm i and after that execute npx react-native run-android
In my case the problem was that I was in the android folder of my project due to this command cd android && ./gradlew assembleRelease.So the solution was to cd ../ and come to root of project and then running this command
react-native run-android --variant=release
ran fine.
For me the issue was I was not inside the project directory AwesomeProject( Project that I created using this command :
react-native init AwesomeProject )
I got it fixed after adding Android sdk-tools to PATH, and restarting VSCode/Terminal.
/Users/<username>/Library/Android/sdk/build-tools
Earlier my path set to
/Users/<username>/Library/Android/sdk
1.make sure java jdk installed
2.make sure npm installed in your project root folder
3.this works for me