React Native CLI Tools
raw JSON →The `react-native-cli` npm package, specifically version 2.0.1 (last updated in 2017), served as the legacy command-line interface for bootstrapping and managing React Native projects. It was designed for global installation, enabling users to create new applications with `react-native init`. However, this package has been superseded; modern React Native development strongly advocates for using `npx react-native` instead. This `npx` approach dynamically fetches and executes the project-local CLI tools (primarily `@react-native-community/cli` or the `react-native` package itself), which ensures compatibility with the specific React Native framework version used in a given project, mitigating issues associated with outdated global CLI installations. The version numbers like v0.85.x seen in recent changelogs refer to the core `react-native` framework package, not this `react-native-cli` wrapper, which has effectively been abandoned.
Common errors
error Sinopia crashes with "Module version mismatch" ↓
sinopia globally (npm uninstall -g sinopia && npm install -g sinopia). If after upgrading Node.js (e.g., to Node 4), you may also need to reinstall npm (npm uninstall -g npm && nvm install npm). error command not found: react-native ↓
npx react-native <command> directly (e.g., npx react-native init MyProject), which does not require a global installation of react-native-cli. If you absolutely need the global react-native command for legacy reasons, ensure npm install -g react-native-cli was run successfully and your shell's PATH includes npm's global bin directory. Warnings
deprecated The `react-native-cli` npm package (version 2.0.1, last released in 2017) is effectively abandoned and no longer the recommended way to interact with React Native CLI features. Global installation can lead to significant compatibility issues with newer React Native framework versions. ↓
gotcha The version numbers like `0.85.x` seen in recent release notes refer to the `react-native` *framework* package, not the `react-native-cli` npm package which remains at `2.0.1` and is outdated. ↓
gotcha When using local development tools like Sinopia with `react-native-cli`, 'Module version mismatch' errors can occur if Node.js versions change between package installations. ↓
Install
npm install react-native-cli yarn add react-native-cli pnpm add react-native-cli Imports
- react-native wrong
npm install -g react-native-cli; react-native init MyProjectcorrectnpx react-native init MyProject - init wrong
react-native init MyProjectcorrectnpx react-native init MyProject --template react-native-template-typescript - start wrong
react-native startcorrectnpx react-native start
Quickstart
// Modern recommended approach using npx to create and manage React Native projects:
console.log("// Step 1: Create a new React Native project (recommended)");
console.log("$ npx react-native@latest init AwesomeProject");
console.log("// This command dynamically fetches the necessary CLI tools and template.");
console.log("// It does not require a global 'react-native-cli' installation.");
console.log("");
console.log("// Step 2: Navigate into your new project directory");
console.log("$ cd AwesomeProject");
console.log("");
console.log("// Step 3: Start the development server (Metro Bundler)");
console.log("$ npx react-native start");
console.log("");
console.log("// Step 4: Run the application on a target platform (e.g., iOS simulator)");
console.log("$ npx react-native run-ios");
console.log("");
console.log("// Legacy approach (not recommended due to package abandonment and potential compatibility issues):");
console.log("// $ npm install -g react-native-cli@2.0.1");
console.log("// $ react-native init DeprecatedProject");
console.log("// This legacy package can cause compatibility issues with newer React Native versions.");