Create React App
Create React App (CRA) is an official command-line interface (CLI) tool for quickly setting up new single-page React applications with zero build configuration. It abstracts away the complex setup of tools like Webpack, Babel, ESLint, and Jest, providing a pre-configured development environment out of the box. The latest version is 5.1.0, though significant updates were last documented in 5.0.1 (April 2022). CRA includes major upgrades to underlying tooling like webpack 5, Jest 27, ESLint 8, and PostCSS 8, along with support for React 18's `createRoot` API and Fast Refresh. While once the primary tool for new React projects, it is now officially deprecated for new applications and in maintenance mode, receiving only critical bug fixes and updates to support newer React versions. It differentiates itself by offering a fully managed, opinionated build setup, aiming for simplicity and a consistent developer experience, making it historically ideal for learning React or starting new projects without extensive build tooling knowledge.
Common errors
-
`create-react-app` is not recognized as an internal or external command
cause `create-react-app` was not installed globally, or `npx` (the recommended method) is not available or working correctly.fixEnsure `npx` is available (comes with npm 5.2+). The recommended way to create a new app is `npx create-react-app my-app`. If you prefer a global install, run `npm install -g create-react-app` (though this is discouraged now). -
Failed to compile. Module not found: Error: Can't resolve 'react'
cause This usually indicates a corrupted `node_modules` directory or an incompatibility between `react-scripts` and other project dependencies, often after an upgrade.fixDelete the `node_modules` directory and `package-lock.json` (or `yarn.lock`), then run `npm install` (or `yarn install`) to reinstall dependencies cleanly. Updating `react-scripts` to the latest compatible version is also advised. -
You are running Node 12.x.x. Create React App requires Node 14 or higher.
cause The installed Node.js version on your system is older than the minimum requirement for Create React App 5.x.fixUpgrade your Node.js version to 14.0.0 or later. Use `nvm install 16` (or desired LTS) and `nvm use 16` to manage Node versions. -
TypeError: (0 , _some_module.default) is not a function
cause Often encountered after upgrading `react-scripts` to v5.0.0, particularly due to changes in ESLint 8 or Babel configuration, leading to issues with default exports or module interoperability.fixEnsure all project dependencies, especially `react-scripts`, `eslint-config-react-app`, and related ESLint plugins, are updated to their latest compatible versions. Review custom ESLint configurations for breaking changes introduced in ESLint 8. Deleting `node_modules` and reinstalling can sometimes help.
Warnings
- breaking Create React App (CRA) is officially deprecated for new projects and is in maintenance mode. The React team now recommends using modern frameworks like Next.js, Remix, or build tools like Vite for new applications, which offer better performance and more features.
- breaking Version 5.0.0 introduced significant dependency upgrades including webpack 5, Jest 27, ESLint 8, and PostCSS 8. This also dropped support for Node.js 10 and 12, requiring Node.js 14 or higher. Custom configurations or older tooling might break.
- breaking Create React App 5.0.1 introduced improvements for React 18 compatibility, including updating templates to use `createRoot` instead of `ReactDOM.render`. Projects upgrading to React 18 with older `react-scripts` versions will need to manually update their `index.js` file.
- gotcha The `eject` command is a one-way operation that permanently removes the managed build configuration, exposing all Webpack, Babel, ESLint, and other configuration files. Once ejected, you are responsible for maintaining and updating all build tooling yourself, and you cannot easily revert to the managed CRA setup.
- gotcha Using an outdated Node.js version (below 14) with Create React App 5.x will lead to installation failures or runtime errors, as it explicitly dropped support for Node 10 and 12.
Install
-
npm install create-react-app -
yarn add create-react-app -
pnpm add create-react-app
Quickstart
npx create-react-app my-new-app cd my-new-app npm start // To create a TypeScript project: npx create-react-app my-ts-app --template typescript cd my-ts-app npm start