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]: Using npx shadcn@latest init #5513

Closed
2 tasks done
tomvanvegchel opened this issue Oct 22, 2024 · 10 comments
Closed
2 tasks done

[bug]: Using npx shadcn@latest init #5513

tomvanvegchel opened this issue Oct 22, 2024 · 10 comments
Assignees
Labels
bug Something isn't working React 19

Comments

@tomvanvegchel
Copy link

Describe the bug

Node version: v20.5.1

I've tried running npx shadcn@latest init aswell as pnpm dlx shadcn@latest init both not going past the "this can take several minutes" message as a fresh project. The longest I've waited is 20 minutes.

I figured I would install a clean next.js project and run it in there to see if maybe the init is stuck on something and not returning it. This resulted in the following error, perhaps related?

image

I am unable to install shadcn ui using the init command in any shape or form. Using it with vite is no problem, that works great.

Affected component/components

x

How to reproduce

  1. Init a new project using: npx shadcn@latest init.
    1. Init a new next.js project using: npx create-next-app@latest
    1. Init npx shadcn@latest init within the new next.js project

Codesandbox/StackBlitz link

Can't reproduce a command

Logs

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

Command failed with exit code 1: npm install tailwindcss-animate class-variance-authority lucide-react @radix-ui/react-icons clsx tailwind-merge
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"19.0.0-rc-65a56d0e-20241020" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.x || ^17.x || ^18.x" from @radix-ui/[email protected]
npm ERR! node_modules/@radix-ui/react-icons
npm ERR!   @radix-ui/react-icons@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /Users/tomvanvegchel/.npm/_logs/2024-10-22T18_01_23_627Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: /Users/tomvanvegchel/.npm/_logs/2024-10-22T18_01_23_627Z-debug-0.log

System Info

MacBook M3 Pro
MacOs: Sonoma 14.4
Node version: v20.5.1

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@tomvanvegchel tomvanvegchel added the bug Something isn't working label Oct 22, 2024
@chhofi
Copy link

chhofi commented Oct 22, 2024

I can confirm having the exact same issue. Running npx shadcn@latest init in a fresh, empty folder and stuck with the message:

npx shadcn@latest init --src-dir button ✔ The path /Users/username/Downloads/testwebsite does not contain a package.json file. Would you like to start a new Next.js project? … yes ✔ What is your project named? … test website ⠋ Creating a new Next.js project. This may take a few minutes.

MacBook M2 Max
MacOs: 15.1
Node version: v22.10.0

@ayuugoyal
Copy link

I got the same issue i think it was because of my cluttered node_modules folder so i just remove the folder and install fresh dependencies and then it works fine for me.

Ubuntu 22
node v22

@chhofi
Copy link

chhofi commented Oct 22, 2024

I got the same issue i think it was because of my cluttered node_modules folder so i just remove the folder and install fresh dependencies and then it works fine for me.

Ubuntu 22 node v22

Unfortunately was not a working solution for me. Also tried brew uninstall node and rm -r /opt/homebrew/lib/node_modules. But the issue persists

@chhofi
Copy link

chhofi commented Oct 22, 2024

All right so I investigated a bit further.

as already seen in your screenshot it comes down to the @radix-ui/[email protected] being not compatible with the newest React 19.0.0 version.

So that is what I did to get it working:

Create a new next.js project without installing the dependencies
npx create-next-app appname --no-install

after you are done cd into the created folder.

There open the file called: package.json
and change the react version: "react": "18.3.1",
"react-dom": "18.3.1",

after that run:

npm install

and than

npx shadcn init

that did the trick for me. And I guess we have to wait till the mentioned package is compatible with the version 19 of React

@RafaelFerreiraTVD
Copy link

Thanks for the fast investigation, I was running into the same error.

@reynaldichernando
Copy link

Another way of fixing this is by running npm install with legacy peer deps npm i --legacy-peer-deps

#5515 (comment)

@shadcn
Copy link
Collaborator

shadcn commented Oct 23, 2024

I've temporarily pinned create-next-app. Keeping an eye on radix-ui/icons#184

@Israel-Okito
Copy link

i found this article, it solves my problem https://www.okitdev.com/posts/comment-resoudre-les-conflits-de-versions-react-avec-radix-ui-react-icons

@NiloyChowdhuryVR
Copy link

I have found a temporary solution, just install the next js,
then in package.json, change the dependency of react and react dom :
"react": "18.3.1", "react-dom": "18.3.1",

then install the shadcn, it will work.
and just wait until radix is compatible with the new react19

@shadcn
Copy link
Collaborator

shadcn commented Oct 28, 2024

I'm working on a fix. Let's use #5557 to track since they are related.

@shadcn shadcn closed this as completed Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working React 19
Projects
None yet
Development

No branches or pull requests

8 participants