shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
74.17k stars 4.58k forks source link

[bug]: Unexpected token when using shadcn add #4671

Open mroxso opened 2 months ago

mroxso commented 2 months ago

Describe the bug

I get the following error when I try to call npx shadcn add seperator.

Error:

⠙ Checking registry.

Something went wrong. Please check the error below for more details.
If the problem persists, please open an issue on GitHub.

Unexpected token '<', "<!DOCTYPE "... is not valid JSON

It is a project that used shadcn-ui. I already did the update in the components.json

I use nextjs 14

Affected component/components

seperator

How to reproduce

  1. Open an existing nextjs 14 (app router) project that contains shadcn-ui
  2. update your components.json file (aliases)
  3. Try to add the seperator with npx shadcn add seperator

Codesandbox/StackBlitz link

No response

Logs

> npx shadcn add seperator

⠙ Checking registry.

Something went wrong. Please check the error below for more details.
If the problem persists, please open an issue on GitHub.

Unexpected token '<', "<!DOCTYPE "... is not valid JSON

System Info

MacOS
Next.js 14

Before submitting

jolbol1 commented 2 months ago

I believe the command should be npx shadcn add separator.

Typo I make all the time 😃

haf commented 2 months ago

Same with npx shadcn@latest add button; is whatever the CLI calls, down? Can I enable verbose logging (not --verbose at least)

jolbol1 commented 2 months ago

npx shadcn@latest add button

This is working for me. Are you able to visit: https://ui.shadcn.com/r/styles/default/button.json on your network? That's what the CLI calls. Replace default with new-york if you were trying that.

haf commented 2 months ago

@jolbol1

image

Curl works

jolbol1 commented 2 months ago

@jolbol1

image

Curl works

Ah, seems its failing for you on the updating files stage, I think its trying to get the color. Whats set in your components.json?

Full list of URL's it tries when running button command, but replace neutral with the color.

https://ui.shadcn.com/r/index.json
https://ui.shadcn.com/r/styles/default/button.json
https://ui.shadcn.com/r/colors/neutral.json
haf commented 2 months ago

It's the GET for the colour violet: I thought I could pick a colour from https://ui.shadcn.com/colors?

jolbol1 commented 2 months ago

At the moment the registry only seems to contain Neutral, Gray, Zinc, Stone, Slate. Not sure why.

Relevant code enforcing this: https://github.com/shadcn-ui/ui/blob/81c7e44863c4f571a9818d5ac55092effbd348f1/apps/www/scripts/build-registry.mts#L583C1-L584C1

Created #4683 which would fix this, and support custom registries as well.

mroxso commented 2 months ago

Oh.. I did not realize there was a typo. Sorry for that. It works now! The error message is a bit confusing though.