What is @react-native-community/cli?
The @react-native-community/cli package is a command-line tool that provides a set of tools to manage and automate tasks in React Native applications. It is designed to streamline the process of initializing, developing, and testing React Native apps. It offers functionalities such as starting a development server, linking native dependencies, and more.
What are @react-native-community/cli's main functionalities?
Initializing a new React Native project
This command sets up a new React Native project named 'AwesomeProject'. It creates a directory with the project name, installs the necessary dependencies, and sets up a basic React Native project structure.
npx react-native init AwesomeProject
Running the React Native application
These commands are used to compile and run your React Native app on Android and iOS devices or emulators. 'run-android' targets Android devices, while 'run-ios' targets iOS devices.
npx react-native run-android
npx react-native run-ios
Linking native dependencies
This command automatically links native dependencies in your project. It scans the project for native modules and configures them for use with React Native, simplifying the manual linking process.
npx react-native link
Other packages similar to @react-native-community/cli
expo-cli
Expo CLI is a command-line tool that provides a set of tools similar to @react-native-community/cli but focuses on projects using the Expo framework. It simplifies the process of developing, building, and deploying React Native apps without needing to open Xcode or Android Studio. Compared to @react-native-community/cli, Expo CLI offers a more managed environment, which can be advantageous for beginners or for projects that can benefit from Expo's additional services and APIs.
ignite-cli
Ignite CLI is a React Native toolchain that helps in initializing and managing React Native projects with additional boilerplates, plugins, and more. It offers a more opinionated setup compared to @react-native-community/cli, including pre-configured boilerplates, plugins, and best practices out of the box. This can help speed up development and enforce consistency across projects.
React Native CLI
Command line tools to interact with React Native projects.
Commands
CLI comes with a set of commands and flags you can pass to them.
Note: This document is still under development and doesn't represent the full API area.
bundle
dependencies
info
install
Usage:
react-native install <packageName>
Installs single package from npm and then links native dependencies. If install
detects yarn.lock
in your project, it will use Yarn as package manager. Otherwise npm
will be used.
library
link
log-android
log-ios
ram-bundle
run-android
run-ios
Usage:
react-native run-ios [options]
Builds your app and starts it on iOS simulator.
Options
--simulator [simulator_name]
Explicitly set the simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version, e.g. "iPhone 6 (10.0)"
.
Default: "iPhone X"
Notes: simulator_name
must be a valid iOS simulator name. If in doubt, open your AwesomeApp/ios/AwesomeApp.xcodeproj folder on XCode and unroll the dropdown menu containing the simulator list. The dropdown menu is situated on the right hand side of the play button (top left corner).
Example: this will launch your projet directly onto the iPhone XS Max simulator:
react-native run-ios --simulator "iPhone XS Max"
--configuration [string]
Explicitly set the scheme configuration to use default: 'Debug'.
--scheme [string]
Explicitly set Xcode scheme to use.
--project-path [string]
Path relative to project root where the Xcode project (.xcodeproj) lives. default: 'ios'.
--device [string]
Explicitly set device to use by name. The value is not required if you have a single device connected.
--udid [string]
Explicitly set device to use by udid.
--no-packager
Do not launch packager while building.
--verbose
Do not use xcpretty
even if installed.
--port [number]
Runs packager on specified port
Default: process.env.RCT_METRO_PORT || 8081
server
uninstall
Usage:
react-native uninstall <packageName>
Unlinks single package native dependencies and then uninstalls it from package.json
. If uninstall
detects yarn.lock
in your project, it will use Yarn as package manager. Otherwise npm
will be used.
unlink
upgrade