{"id":17009,"library":"generate-react-cli","title":"Generate React CLI","description":"generate-react-cli is a command-line interface tool designed to streamline the creation of React components, aiming to boost developer productivity by automating repetitive setup tasks. The current stable version is 11.0.4, released in April 2026. This package maintains a somewhat frequent release cadence, with multiple minor and patch releases occurring monthly or bi-monthly, and major versions typically updating Node.js requirements or tooling support. Its key differentiators include an initial interactive configuration that generates a `generate-react-cli.json` file, allowing project-specific defaults for TypeScript usage, CSS modules, various CSS preprocessors (like SCSS), and testing libraries (React Testing Library, Vitest, or no tests). It offers extensive customization through command-line options and support for custom component types, templates, and file structures, enabling developers to quickly scaffold components, pages, or layouts according to their project's conventions.","status":"active","version":"11.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/arminbro/generate-react-cli","tags":["javascript","cli","react","build-tools","generate-react-cli"],"install":[{"cmd":"npm install generate-react-cli","lang":"bash","label":"npm"},{"cmd":"yarn add generate-react-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add generate-react-cli","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[],"quickstart":{"code":"npx generate-react-cli component Box\n\n# The first command will prompt you to configure the CLI, creating a\n# 'generate-react-cli.json' file. Then it generates a 'Box' component.\n\n# Subsequent runs can override configured defaults using options:\nnpx generate-react-cli component Button --withTest=false --withStory=true\n\n# For global installation (less recommended for CI/CD environments):\nnpm i -g generate-react-cli\ngenerate-react component Navbar","lang":"javascript","description":"Demonstrates how to generate a new React component using `npx`, prompting for initial configuration if run for the first time, and showing how to override default settings via command-line options."},"warnings":[{"fix":"Upgrade your Node.js installation to version 22 or newer to use versions 10.0.0 and above of this CLI tool. You can use nvm to manage multiple Node.js versions.","message":"Minimum Node.js version required to run `generate-react-cli` has been raised to 22.0 or higher.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Update your `generate-react-cli.json` configuration to use 'Testing Library', 'Vitest', or 'None' for the `testLibrary` option. Migrate any existing Enzyme tests to the new framework as needed.","message":"Support for the Enzyme testing library has been removed. Projects using Enzyme for tests will need to migrate to Testing Library or Vitest.","severity":"breaking","affected_versions":">=11.0.0"},{"fix":"Review the generated `generate-react-cli.json` to customize default paths, styling, and testing preferences according to your project's conventions. These defaults can always be overridden with command-line options for specific generations.","message":"The CLI generates a `generate-react-cli.json` configuration file in your project root on its first run. This file dictates default settings for component generation.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Upgrade your Node.js environment to version 22 or newer. Using a Node Version Manager (nvm) is recommended for easy switching: `nvm install 22 && nvm use 22`.","cause":"The installed version of Node.js does not meet the minimum requirement (Node.js 22 or higher) for `generate-react-cli` versions 10.0.0 and above.","error":"Error: You are running Node.js <22."},{"fix":"Run `npx generate-react-cli component MyComponent` once. This command will interactively prompt you to set up initial configurations and then create the `generate-react-cli.json` file in your project root.","cause":"The configuration file `generate-react-cli.json` is missing from your project root, or the CLI has not been run previously to create it automatically.","error":"Error: generate-react-cli.json: No such file or directory"},{"fix":"Verify the `usesCssModule` and `cssPreprocessor` settings in your `generate-react-cli.json`. Ensure `withStyle` is `true` if you expect a style file. Adjust your project's Webpack/Vite configuration to correctly handle CSS modules if necessary.","cause":"The generated component is attempting to import a CSS module, but either the `usesCssModule` setting in `generate-react-cli.json` or the `--withStyle` option was incorrectly configured for your project's styling setup, or the style file was not generated as expected.","error":"Cannot find module 'YourComponentName.module.css' (or similar style import error)"}],"ecosystem":"npm","meta_description":null}