Skip to content
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

Error when running nx run ui-lib:add-component .... due to 'shadcn-ui' not being recognized #309

Closed
thealirexa opened this issue Sep 1, 2024 · 7 comments · Fixed by #341

Comments

@thealirexa
Copy link

Description

When trying to add a component using the command nx run ui-lib:add-component card, I encountered an error indicating that shadcn-ui is not recognized as a command.

It worked yesterday, but today it doesn't! I think it's due to the shadcn/cli upgrade!

Command Run

nx run ui-lib:add-component card

Output/Error Message

Running:
npx shadcn-ui@latest add card --path=src --cwd=ui-lib
'shadcn-ui' is not recognized as an internal or external command,
operable program or batch file.

—————————————————————————————————————————————————————————————————————————————————————————————————————————————— 

 NX   Ran target add-component for project ui-lib (3s)

      With additional flags:
        card

   ×  1/1 failed
   √  0/1 succeeded [0 read from cache]

Expected Behavior

The command should successfully add the card component to the project without any errors.

Steps to Reproduce

  1. Run nx run ui-lib:add-component card.
  2. Observe the error related to shadcn-ui.

Additional Context

If this issue is specific to my environment or setup, please let me know if there are any dependencies or steps I might be missing.

@SinPP
Copy link

SinPP commented Sep 17, 2024

I can confirm the same error happening with a fresh installation of today

@TriPSs
Copy link
Owner

TriPSs commented Sep 17, 2024

Hmm, you can run like this NX_EXTEND_COMMAND_USE_NPX=true nx run ui-lib:add-component card and in the meantime I will check it out.

@SinPP
Copy link

SinPP commented Sep 17, 2024

image

For whatever reason it complains that sahadcn-ui is not found, even though it is installed locally, globally and through npx should be no problem whatsoever.

Edit:
Command: NX_EXTEND_COMMAND_USE_NPX=true nx run ui-admin:add-component card

@dongjin2008
Copy link

Are there any solutions yet?

@TriPSs
Copy link
Owner

TriPSs commented Sep 23, 2024

Aperently they changed the CLI https://ui.shadcn.com/docs/changelog.

@murbanowicz
Copy link

@TriPSs any chance to get it fixed soon? Don't want to be nasty or so, so don't take me like that. Just asking because your plugin came as life-saver for me, but I hit this wall unfortunately :(

@TriPSs
Copy link
Owner

TriPSs commented Sep 27, 2024

To be honest here: I did a quick look and did not get anything working yet, I am still using the plugin but not very actively so think I will fix this once I need it again.

I can still try to fix the version that is being used, maybe that helps.

And of course: any PR fixing this is also appreciated.

@TriPSs TriPSs closed this as completed in c940745 Oct 22, 2024
TriPSs added a commit that referenced this issue Oct 22, 2024
The latest version of the UI package does not include the CLI anymore,
it's published under `shadcn` now - this PR fixes that by pinning the
version to `0.8.0`, the latest previous version that works.

It would be nice to start using the new CLI, but it's incompatible with
the current setup inside NX: it expects package.json and components.json
to be defined within the same directory. I think the better approach
would be to implement a NX-specific version of the `add` command instead
of using the upstream CLI - it's [not particularly
complex](https://github.com/shadcn-ui/ui/blob/main/packages/cli/src/commands/add.ts).
TriPSs added a commit that referenced this issue Nov 15, 2024
Fix #309 #340

Move `shadcn-ui` CLI to `shadcn` CLI for add components.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants