Command line tools to interact with React Native projects.
CLI comes with a set of commands and flags you can pass to them.
bundle
dependencies
info
install
library
link
log-android
log-ios
ram-bundle
run-android
run-ios
start
uninstall
unlink
upgrade
Note: This document is still under development and doesn't represent the full API area.
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.
Usage:
react-native link [packageName]
Link native dependency or all native dependencies if no packageName
passed.
Pass comma-separated list of platforms to scope link
to.
Usage:
react-native run-ios [options]
Builds your app and starts it on iOS simulator.
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"
Explicitly set the scheme configuration to use default: 'Debug'.
Explicitly set Xcode scheme to use.
Path relative to project root where the Xcode project (.xcodeproj) lives. default: 'ios'.
Explicitly set device to use by name. The value is not required if you have a single device connected.
Explicitly set device to use by udid.
Do not launch packager while building.
Do not use xcpretty
even if installed.
Runs packager on specified port
Default: process.env.RCT_METRO_PORT || 8081
Usage:
react-native start [option]
Starts the server that communicates with connected devices
Specify port to listen on
Specify any additional folders to be added to the watch list
Specify any additional asset extensions to be used by the packager
Specify any additional source extensions to be used by the packager
Specify any additional platforms to be used by the packager
Specify any npm packages that import dependencies with providesModule
Specifies the maximum number of workers the worker-pool will spawn for transforming files. This defaults to the number of the cores available on your machine
Disable flow checks
Disable file watcher
Specify a custom transformer to be used
Removes cached files
Path to a JavaScript file that exports a log reporter as a replacement for TerminalReporter
Enables logging
Enables https connections to the server
Path to custom SSL key
Path to custom SSL cert
Path to the CLI configuration file
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.
Usage:
react-native unlink <packageName>
Unlink native dependency linked with the link
command.
Usage:
react-native upgrade [npm-version]
Upgrade your app's template files to the specified or latest npm version using rn-diff-purge project. Only valid semver versions are allowed.
Using this command is a recommended way of upgrading relatively simple React Native apps with not too many native libraries linked. The more iOS and Android build files are modified, the higher chance for a conflicts. The command will guide you on how to continue upgrade process manually in case of failure.
Note: If you'd like to upgrade using this method from React Native version lower than 0.59.0, you may use a standalone version of this CLI: npx @react-native-community/cli upgrade
.