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

[bug]: add --path is broken #6202

Open
2 tasks done
lacymorrow opened this issue Dec 28, 2024 · 3 comments
Open
2 tasks done

[bug]: add --path is broken #6202

lacymorrow opened this issue Dec 28, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@lacymorrow
Copy link

Describe the bug

I haven't found any combination of arguments to get a custom path out of the add function

options.path ? path.resolve(cwd, options.path) : undefined

I noticed in the code that it resolves CWD, but passing that as an option as well doesn't work

const cwd = path.resolve(options.cwd)

Affected component/components

CLI

How to reproduce

npx shadcn@latest add -c . --path src button

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Node 22, NPM 10.9.0

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@lacymorrow lacymorrow added the bug Something isn't working label Dec 28, 2024
@DemaPy
Copy link

DemaPy commented Dec 28, 2024

Hi, did you check this one?

Usage: shadcn add [options] [components...]

add a component to your project

Arguments:
  components         the components to add or a url to the component.

Options:
  -y, --yes          skip confirmation prompt. (default: false)
  -o, --overwrite    overwrite existing files. (default: false)
  -c, --cwd <cwd>    the working directory. defaults to the current directory.
  -a, --all          add all available components. (default: false)
  -p, --path <path>  the path to add the component to.
  -h, --help         display help for command

@lacymorrow
Copy link
Author

Yep! That's what I'm referring to, see the reproduction steps. I am unable to get any path to work, the cli defaults to what is in components.jaon

@ArchiFloyd
Copy link

ArchiFloyd commented Jan 17, 2025

This happens for me when I try to add a component to a non-existing folder path. I tried adding components via Powershell and on a Arch Linux WSL2 running bash. Both running node lts/iron (20.18.0) and npm (10.8.2).

If I try to pre-create a folder and point the path argument to that it states that no package.json file was find and then it asks me if I want to start a new Next.js project there. Same happens if i try to point it to a path that end in .tsx.

Either it is broken else the documentation is too scarce

EDIT:

If I try to pre-create a folder and point the path argument to that it states that no package.json file was find and then it asks me if I want to start a new Next.js project there. Same happens if i try to point it to a path that end in .tsx.

This part isn't true. I was trying to invoke the npx shadcn@latest add from the subfolder, which of course didn't work. In all cases I've tried I get the same result - it's trying to overwrite the existing component that exist in the path from the components.json file and the path argument is not respected at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants