Create React App Scripts
react-scripts is the core package underpinning Create React App (CRA), providing the fundamental configuration and scripts (start, build, test, eject) for React applications without requiring manual Webpack, Babel, ESLint, or Jest setup. The current stable version is 5.0.1, released in April 2022. Historically, major versions were released approximately annually, with maintenance patches in between. Key differentiators include its 'zero-configuration' approach, abstracting away complex build tooling, and offering a consistent development experience. While highly popular for rapid prototyping and learning, Create React App, and by extension `react-scripts`, is now in a maintenance state and is no longer recommended for new projects, which are encouraged to use alternative build tools like Vite or Next.js.
Common errors
-
npm ERR! code EBADENGINE npm ERR! engine Unsupported engine for react-scripts@5.0.1: wanted: {"node": ">=14.0.0"} (current: {"node":"12.x.x"})cause Using an incompatible Node.js version (older than 14.0.0) with react-scripts v5.x.fixUpgrade your Node.js version to 14.0.0 or higher. Use nvm (e.g., `nvm install 16 && nvm use 16`) or volta to manage your Node.js environment. -
Module not found: Error: Can't resolve 'react-dom/client' in '/path/to/your/project/src'
cause Attempting to use React 18's `createRoot` API without updating react-scripts to at least v5.0.1, or without installing React 18 itself.fixEnsure you have `react` and `react-dom` versions 18.x installed (`npm install react react-dom`) and that `react-scripts` is at least `5.0.1`. Then, update your `src/index.js` or `src/index.tsx` to use `import { createRoot } from 'react-dom/client';`. -
ESLint: 'Component' is defined but never used. (no-unused-vars) OR ESLint: Parsing error: The keyword 'import' is reserved.
cause ESLint rules or configuration changed significantly in react-scripts v5.0.0 due to the upgrade to ESLint 8, or a conflicting ESLint config is present.fixReview your project's ESLint configuration (e.g., `.eslintrc.json` if ejected or created one). For `no-unused-vars`, consider explicit unused variable prefixes. For parsing errors, ensure your ESLint parser supports modern JS/TS syntax and react-scripts' default config is not overly overridden. -
TypeError: (0 , _webpackDevServer.default) is not a function OR Webpack build fails with module not found for custom configurations.
cause Incompatibility issues arising from the major Webpack 5 upgrade in react-scripts v5.0.0, often related to custom configurations or `react-app-rewired`.fixRemove or update any custom Webpack configurations or libraries like `react-app-rewired` that modify the default react-scripts behavior, as they might be incompatible with Webpack 5. Refer to the Webpack 5 migration guide if manual intervention is required.
Warnings
- breaking Upgrading to react-scripts v5.0.0 introduced significant upgrades to core development dependencies including Webpack 5, Jest 27, ESLint 8, and PostCSS 8. These upgrades can lead to breaking changes in build configurations, ESLint rules, and testing setups if custom configurations or older plugins were in use.
- breaking When using React 18 with react-scripts v5.0.1, applications must migrate from `ReactDOM.render` to `ReactDOM.createRoot` for client-side rendering. Failing to do so will result in React 18 features (like concurrent rendering) not being enabled and potential console warnings.
- gotcha Create React App (and by extension, react-scripts) is officially in maintenance mode and is no longer recommended for new projects. While existing projects can continue to use it, new projects are advised to explore modern alternatives like Vite, Next.js, or Remix for better performance, built-in features, and an active ecosystem.
- breaking react-scripts v4.0.0 introduced support for React 17's new JSX transform and Fast Refresh. While beneficial, custom Babel configurations or older tooling might conflict, requiring adjustments, especially if the `react-app/babel` preset is overridden or if `babel-plugin-react-jsx` was manually added.
- gotcha react-scripts v5.x requires Node.js version 14.0.0 or higher. Using an older Node.js version will prevent the scripts from running, resulting in an `EBADENGINE` error during installation or execution.
Install
-
npm install react-scripts -
yarn add react-scripts -
pnpm add react-scripts
Quickstart
// Create a new React project using Create React App (this installs react-scripts)
// This command initializes a new project with react-scripts as a dependency.
// react-scripts itself is not typically imported into application code directly.
// The primary interaction is via CLI commands managed by npm/yarn scripts.
// 1. Initialize a new project with TypeScript template (recommended for new CRA projects)
// npx create-react-app my-new-app --template typescript
// (Alternatively, for JavaScript projects:)
// npx create-react-app my-new-app
// 2. Navigate into the newly created project directory
// cd my-new-app
// 3. Start the development server
// npm start
// (or yarn start)
// 4. Build the project for production deployment
// npm run build
// (or yarn build)
// 5. Run tests
// npm test
// (or yarn test)
// Example of a minimal component inside src/App.tsx after project creation:
import React from 'react';
import logo from './logo.svg';
import './App.css';
function App(): JSX.Element {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://react.dev"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;