The latest React Native Doctor Command

We pride ourselves in always being up to date with the latest updates from our favorite networks and, in this article, we’ll be focusing on React Native’s latest command, called React Native Doctor, which is great for troubleshooting and fixing errors.

Let’s start with some context: the last stable version of React Native is 0.61 (which includes the fast refresh feature that we love so much). This version doesn’t come with the doctor command in the CLI, but the good news is that you can still use it by running `npx @react-native-community/cli doctor`.

The version that will include the doctor command by default is version 0.62 which is a current RC and will probably be ready soon. This command will come with the CLI and you’ll be able to execute it by merely writing `react-native doctor`.

Now, let’s go into more detail.

Supported checks (as of now)

doctor currently supports the following checks:

  • Node.js (>= 8.3)
  • yarn (>= 1.10)
  • npm (>= 4)
  • Watchman (>= 4), used for watching changes in the filesystem when in development mode.

Specific to the Android environment:

  • Android SDK (>= 26), the software runtime for Android.
  • Android NDK (>= 19), the native development toolkit for Android.
  • ANDROID_HOME, the environment variable required by the Android SDK setup.

Specific to the iOS environment:

  • Xcode (>= 10), IDE for developing, building and shipping iOS applications.
  • CocoaPods, a library dependency management tool for iOS applications.
  • ios-deploy (optional), a library used internally by the CLI to install applications on a physical iOS device.

How does it work?

The doctor command, as mentioned in the React Native blog, supports most of the software and libraries that React Native relies on, such as CocoaPods, Xcode and Android SDK. 

By using this command, you can discover any issues caused by the development environment and fix them automatically.

React Native Doctor Video

In this video, you can see both the execution and the response after running the diagnostic. You can choose the f option to fix all the issues found by the command and as a result, as you can see, there aren’t any more issues to be fixed. 

There are some issues doctor cannot fix, but in that case, this information would be displayed with the corresponding link so you can fix them manually. 

Doctor Command

Why is React Native Doctor so important?

Before the doctor command, we used to execute `react-native info`, which would end up only providing us with only information and no further action. 

Using the `doctor` command automatically fixes errors with your development environment in a similar way to how `brew doctor` works. 

React Native Doctor Command

React Native Doctor final thoughts

This might seem like it’s not a big deal, but by running doctor, you can spend more time building your apps rather than fixing the issues, therefore making the development process a lot faster and entertaining.