Skip to content

React library generator doesn't work using --routing flag #30721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 of 4 tasks
manuelbosi opened this issue Apr 14, 2025 · 0 comments · May be fixed by #30722
Open
1 of 4 tasks

React library generator doesn't work using --routing flag #30721

manuelbosi opened this issue Apr 14, 2025 · 0 comments · May be fixed by #30722
Assignees
Labels
priority: medium Medium Priority (not high, not low priority) scope: react Issues related to React support for Nx type: bug

Comments

@manuelbosi
Copy link

Current Behavior

Generating a new react library doesn't work if routing flag is set to true.

Expected Behavior

React library generator should work using the --routing=true flag

GitHub Repo

No response

Steps to Reproduce

  1. Create new nx project: pnpm dlx create-nx-workspace --pm pnpm
  2. Add @nx/react package: pnpm nx add @nx/react
  3. Generate a react library: pnpm nx g @nx/react:library --directory=packages/my-react-lib --name=my-react-lib --routing=true --no-interactive --dry-run
  4. The command will fails

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.13.1
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.8.0

nx                     : 20.7.2
@nx/js                 : 20.7.2
@nx/eslint             : 20.7.2
@nx/workspace          : 20.7.2
@nx/devkit             : 20.7.2
@nx/eslint-plugin      : 20.7.2
@nx/module-federation  : 20.7.2
@nx/react              : 20.7.2
@nx/vite               : 20.7.2
@nx/web                : 20.7.2
typescript             : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/eslint/plugin
@nx/react/router-plugin
---------------------------------------
Cache Usage: 195.29 KB / 92.64 GB

Failure Logs

pnpm nx g @nx/react:library --directory=packages/my-react-lib --name=my-react-lib --routing=true --no-interactive --dry-run

 NX  Generating @nx/react:library

Error in node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@swc+_b4a36daeda0a39830e1b1fa2cefb5f75/node_modules/@nx/react/src/generators/component/files/__fileName__.__ext__:

 NX   /node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_@swc+_b4a36daeda0a39830e1b1fa2cefb5f75/node_modules/@nx/react/src/generators/component/files/__fileName__.__ext__:56

    54| <%_ if (routing) { _%>
    55|         <ul>
 >> 56|           <li><Link to="/"><%= name %> root</Link></li>
    57|         </ul>
    58|         <Route path="/" element={<div>This is the <%= name %> root route.</div>} />
    59| <%_ } _%>

name is not defined
Pass --verbose to see the stacktrace.

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@FrozenPandaz FrozenPandaz added priority: medium Medium Priority (not high, not low priority) scope: react Issues related to React support for Nx labels Apr 14, 2025
manuelbosi added a commit to manuelbosi/nx that referenced this issue Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium Medium Priority (not high, not low priority) scope: react Issues related to React support for Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants