reflex-dev/reflex · error · SystemExit

Could not find module {config.module}.

Error message

Could not find module {config.module}.

What it means

Raised by `reflex.utils.rename.rename_app` when the module path computed from `config.module` cannot be located on disk. Before renaming an app, Reflex resolves the module in rxconfig.py to a filesystem path; if `get_module_path` returns None the app directory cannot be found and the rename aborts via SystemExit(1). It almost always means rxconfig.py declares a module name that doesn't match the actual directory/file layout.

Source

Thrown at reflex/utils/rename.py:81

    Raises:
        SystemExit: If the command is not ran in the root dir or the app module cannot be imported.
    """
    # Set the log level.
    console.set_log_level(loglevel)

    if not constants.Config.FILE.exists():
        logger.error(
            "No rxconfig.py found. Make sure you are in the root directory of your app."
        )
        raise SystemExit(1)

    sys.path.insert(0, str(Path.cwd()))

    config = get_config()
    module_path = get_module_path(config.module)
    if module_path is None:
        logger.error(f"Could not find module {config.module}.")
        raise SystemExit(1)

    logger.info(f"Renaming app directory to {new_app_name}.")
    process_directory(
        Path.cwd(),
        config.app_name,
        new_app_name,
        exclude_dirs=[constants.Dirs.WEB, constants.Dirs.APP_ASSETS],
    )

    rename_path_up_tree(module_path, config.app_name, new_app_name)

    logger.log(
        log.SUCCESS,
        f"App directory renamed to [bold]{escape(new_app_name)}[/bold].",
        extra={"rich": True},
    )

View on GitHub (pinned to 45b8ed5ab7)

Solutions

  1. Verify you are in the project root and that the directory (or my_app.py) named by config.module in rxconfig.py actually exists; fix the module name in rxconfig.py if it drifted.
  2. If the directory was already renamed manually, update rxconfig.py to the current name instead of running `reflex rename` again.
  3. Re-run `reflex rename <new_name>` once module and directory agree.

Example fix

# before (rxconfig.py)
config = rx.Config(app_name="old_name")  # but directory is my_app/

# after
config = rx.Config(app_name="my_app")  # matches ./my_app
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
import reflex.utils.format as fmt

def can_rename() -> bool:
    from reflex.config import get_config
    module = get_config().module
    return (Path.cwd() / module).is_dir() or (Path.cwd() / f"{module}.py").is_file()

Prevention

When it happens

Trigger: Running `reflex rename <new_name>` (or calling rename/rename_app) when config.module (e.g. "my_app") does not correspond to an existing my_app/ directory or my_app.py file in the current working directory.

Common situations: rxconfig.py was hand-edited so app_name/module no longer match the directory; the command is run from the wrong directory (not the project root); the app directory was already moved/renamed manually; sys.path doesn't include cwd so module discovery fails.

Related errors


AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28). Data as JSON: /api/errors/f7a1b875ddc13a70. Report an issue: GitHub.