Skip to main content
  1. All Posts/

cli

Tools TypeScript

React Native CLI

Command line tools that ship with react-native in form of the @react-native-community/cli package.

It exposes react-native binary, so you can call yarn react-native or npx react-native directly from your project.


Note: CLI has been extracted from core react-native as a part of “Lean Core” effort. Please read this blog post for more details.

Contents

Compatibility

Our release cycle is independent of react-native. We follow semver and here is the compatibility table:

@react-native-community/cli
react-native

^9.0.0
^0.70.0

^8.0.0
^0.69.0

^7.0.0
^0.68.0

^6.0.0
^0.65.0,^0.66.0,^0.67.0

^5.0.0
^0.64.0

^4.0.0
^0.62.0,^0.63.0

^3.0.0
^0.61.0

^2.0.0
^0.60.0

^1.0.0
^0.59.0

Documentation

  • configuration
  • commands
  • plugins
  • init
  • autolinking

About

This monorepository contains tools and helpers for React Native projects in form of a Command Line Tool (or CLI). This CLI is used directly by the react-native package and is not intended for use directly. We update it independently of React Native itself.

Creating a new React Native project

Run the following command in your terminal prompt:

npx react-native init MyApp

Usage in an existing React Native project

Once you’re inside an existing project, a local react-native binary will be available for you to use. Feel free to use Yarn to call it directly.
Example running start command in terminal:

yarn react-native start
# or:
npx react-native start

You can also add npm scripts to call it with whichever package manager you use:

{
  "scripts": {
    "start": "react-native start"
  }
}

Updating the CLI

React Native CLI is a dependency of react-native, which makes it a transitive dependency of your project. It happens that you may be locked on a version without fixes for bugs that may affect you. Here’s how to get it sorted:

  1. If you use lock files (yarn.lock or package-lock.json) – find all the @react-native-community/cli prefixed entries, remove them, run yarn install / npm install once again.
    Here’s an example using yarn.lock. Notice how whole @react-native-community/cli entries are removed. Make sure to delete all of them:

    diff --git a/yarn.lock b/yarn.lock
    index 073309f..0bb8c4b 100644
    --- a/yarn.lock
    +++ b/yarn.lock
    @@ -843,26 +843,6 @@
         "@types/istanbul-reports" "^1.1.1"
         "@types/yargs" "^13.0.0"
    

    -"@react-native-community/cli-debugger-ui@^3.0.0":

  2. If you don’t use lock files – remove node_modules and run yarn install / npm install again.
  3. Run yarn list --pattern @react-native-community/cli or npm list @react-native-community/cli and verify you’re on the latest version.

After performing these steps you should be on the latest CLI version. Feel free to do it once in a while, because we release often.

Maintainers

Previously:

  • Mike Grabowski (@grabbou) – Callstack
  • Kacper Wiszczuk (@esemesek)

License

Everything inside this repository is MIT licensed.