react-dev-utils is a collection of internal utility modules primarily used by Create React App (CRA) to abstract and manage webpack configurations, development server setups, build processes, and other development-related tasks. It includes tools for error formatting, path resolution, webpack plugin management like `ModuleScopePlugin`, and environment variable handling. The package is not typically consumed directly by applications but rather by build tools like `react-scripts`. Its versioning and release cadence are tightly coupled with `react-scripts`, making direct maintenance releases uncommon outside of major `react-scripts` updates. The current stable version of `react-dev-utils` is 12.0.1, which corresponds to `react-scripts` v5.x.x. This version incorporates significant updates such as webpack 5, Jest 27, and ESLint 8, ensuring compatibility with modern JavaScript ecosystems. It provides a standardized and optimized development experience for CRA projects, significantly minimizing configuration overhead for developers by encapsulating complex build logic. Developers typically interact with these utilities indirectly through `react-scripts` commands, though advanced users might import specific modules for custom setups, especially in ejected CRA applications.
npm install react-dev-utilsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to set up a custom webpack development server using `react-dev-utils` for port selection, URL preparation, and dev server configuration, mimicking Create React App's internal logic. This example uses `webpack`, `webpack-dev-server`, and several utilities from `react-dev-utils` to initialize and manage the server.
For ejected projects, carefully review release notes for webpack, Jest, ESLint, and PostCSS. Manually update webpack configurations, Jest setups, ESLint rules, and PostCSS plugins to be compatible with their new major versions. Refer to the `react-scripts` v5 migration guide for common patterns.
Ensure your project's `tsconfig.json` is configured for TypeScript 4 if using TypeScript. For React 17, the new JSX transform might require no changes or minor adjustments depending on your Babel configuration, but be aware of its implications for global React import requirements.
If directly consuming `react-dev-utils`, be prepared for potential undocumented breaking changes. Consider carefully whether directly importing is necessary, or if extending `react-scripts` (e.g., via tools like `craco`) is a more stable approach.
Always ensure your `react-scripts` package (and by extension, `react-dev-utils` if used directly) is updated to the latest stable patch version to mitigate any reported security vulnerabilities, even if they are described as non-impacting for CRA projects.
Ensure all your application code and components are located within the `src` directory or any other directories explicitly configured to be within the module scope. If you genuinely need to import from outside, you might need to eject and modify the webpack configuration, or use tools like `craco` to override the `ModuleScopePlugin`.
Review the `WebpackDevServerUtils` source or latest `react-scripts` webpack configuration to understand the current usage. Ensure `WebpackDevServer` is correctly imported (e.g., `import WebpackDevServer from 'webpack-dev-server';`) and its constructor is called with the expected arguments, often including a configuration object and a webpack compiler instance.
If you have a custom `.eslintrc` file or ESLint plugins, update them to be compatible with ESLint v8. Check the ESLint v8 migration guide for details on rule changes and plugin compatibility. Ensure all ESLint-related packages are also updated to their latest versions.
No dependency data recorded yet.