ui: [bug]: Installation fails with Next.js 15 and/or React 19
Describe the bug
While initializing a new Next.js project with shadcn-ui using npx shadcn@latest init, the installation fails when attempting to install dependencies. The error occurs because @radix-ui/react-icons has a peer dependency requirement for “react@^16.x || ^17.x || ^18.x”, but the project is using React 19.0.0-rc-69d4b800-20241021.
Error message: npm error ERESOLVE unable to resolve dependency tree npm error Found: react@19.0.0-rc-69d4b800-20241021 npm error Could not resolve dependency: npm error peer react@“^16.x || ^17.x || ^18.x” from @radix-ui/react-icons@1.3.0
Current environment:
- Next.js 15
- React 19.0.0-rc-69d4b800-20241021
- npm (latest version)
- shadcn-ui (latest version)
The installation works fine with React 18, suggesting that @radix-ui/react-icons needs to be updated to support React 19 release candidates.
Potential solutions:
- Update @radix-ui/react-icons peer dependencies to include React 19
- Add a note in the documentation about React 19 compatibility
- Add a version check in the CLI to warn users about React 19 compatibility issues
Affected component/components
shadcn-ui installation fails
How to reproduce
Steps to reproduce:
1. Create a new Next.js project with experimental features:
```bash
npx create-next-app@latest my-app --typescript --tailwind --app
-
During the setup, select ‘yes’ for App Router and other default options
-
Navigate to the project directory: bash cd my-app
-
Try to initialize shadcn-ui: bash npx shadcn@latest init
-
Select configuration options:
- Style: New York
- Base color: Neutral
- CSS variables: Yes
-
The installation will fail during the dependency installation step with the following error:
npm error ERESOLVE unable to resolve dependency tree npm error Found: react@19.0.0-rc-69d4b800-20241021 npm error Could not resolve dependency: npm error peer react@“^16.x || ^17.x || ^18.x” from @radix-ui/react-icons@1.3.0
You can verify the React version in your package.json: { “dependencies”: { “react”: “19.0.0-rc-69d4b800-20241021”, “react-dom”: “19.0.0-rc-69d4b800-20241021” } }
Codesandbox/StackBlitz link
No response
Logs
No response
System Info
System Information:
Operating System:
- Windows 8
- Working in Command Prompt
Node Environment:
- Node.js version: v20.17.0
- npm version: v10.9.0
Project Dependencies:
- Next.js: 15
- React: 19.0.0-rc-69d4b800-20241021
- React DOM: 19.0.0-rc-69d4b800-20241021
- Typescript: ^5
- Tailwind CSS: ^3.4.1
CLI Versions:
- create-next-app: latest
- shadcn-ui CLI: latest (@shadcn/ui)
Additional Context:
- Fresh installation with default configurations
- Using App Router
- Project created with TypeScript and Tailwind CSS enabled
Before submitting
- I’ve made research efforts and searched the documentation
- I’ve searched for existing issues
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 42
- Comments: 88 (13 by maintainers)
Commits related to this issue
- Fix: Fe Shadcn currently conflicts with react 19. Fix this error by reinstalling shadcn. Ref https://github.com/shadcn-ui/ui/issues/5557 https://ui.shadcn.com/docs/react-19 — committed to muroa96/wishdev by muroa96 2 years ago
- fix: resolve react-day-picker installation error using package.json overrides - Reference: https://github.com/shadcn-ui/ui/issues/5557#issuecomment-2725349719 — committed to netr/timetrack by netr 2 years ago
You can also use:
npm config set legacy-peer-deps truecheck the blog solve this problem https://tutorialsmaterial.com/post/ShadCn-Nextjs-15
Solution is to install
react@18andreact-dom@18. It’ll temporarily solve the issue.Yes
Use Nextjs 14
npx create-next-app@14
I found a solution. Use pnpm package manager
you can use overrides for a temporary fix.
Is this bug resolved now? I am so cold, because my boss asked me to blow cold air until it can be solved
@kurorinto Solution for me was:
npm install react@18.2.0 react-dom@18.2.0
You can solve this issue by installing react 18 . I tried and it’s working fine for me
Yikes… you guys should fix this, my first dive into using ShadCN ended in a brick wall here… the proposed workarounds are way to dangerous, one must assume they will result in dependency conflict or become permanent if its been this way for 6 months already.
Problem with calendar still persists.
Any solutions ?
I’m bringing back the flags (temporarily).
It happened to me when I wanted to use the Date Picker component, I don’t remember well, but what I remember is that I installed
date-fnsusingnpm install date-fns, and that gave me an error, I fixed it by doing this: uninstalling it, and then runningnpx shadcn@latest add calendarand that installed the correct version ofdate-fns.What is actually required for ShadCN to support React 19? I’ll start a list:
This is the full error:
I decided to try in a fresh nextjs project.
npx create-next-app test-shadcnThen install shadcn
npx shadcn@latest initThe above command throws me this error:
As temporal fix, it worked to execute this command
I need this urgently, is there any other solution for this ?
I’m still running into this issue w/ bun
and when using
<FormControl>:I think one thing that can be done is to use
--legacy-peer-depstry to run in the command prompt
npm install shadcn --legacy-peer-depsI am unsure about this command, please let me know if it works.
I also see this issue.
For NextJS15 and React19, if you use
bun, add this. I think this is a temporary solution!I’m unsure what went wrong with shadcn; it also doesn’t work with the previous version of next.js. I am using version
14.2.16.@Jacksonmills thanks for the detailed write-up. I’m surprised this is still an issue. Tested this a few times yesterday. I’ll take a look.
wrong link in the shadcn docs https://ui.shadcn.com/docs/installation/next
Leads to a 404
Update: https://ui.shadcn.com/docs/react-19. Please take a look and let me know. Thank you.
@Jacksonmills prod. thanks.
(Yes it looks like it’s working but I have a fix on the way as well)
i got this like error but u can fix in
package.jsonreact version must less that 18; and also react dom less 18;Hey @TaifurIslamAshraf,
I tested out this scenario and was able to get shadcn-ui running smoothly with the New York theme and the
@radix-ui/react-iconspackage.Here’s what I did:
npx shadcn/ui@latest init, using New York as the style and including@radix-ui/react-icons.npx shadcn/ui@latest add ...and made sure to use some icons from@radix-ui/react-icons.npx @next/codemod@canary upgrade latest.@radix-ui/react-iconsicon on the homepage for testing.Everything worked both locally and in production without issues.
Prod links: Home page Dashboard page
For reference, here are some key details about my setup:
@radix-ui/react-icons: ^1.3.0Feel free to check out the repo directly here: GitHub Repo to make sure everything is set up correctly. Let me know if you need more details or if there’s anything else I can help test!
Yeah, it is also coming for me do you got any solution ?
@L3on06 oh sorry. I was replying to the original post about
initfailing. The calendar work is still in progress. Once Tailwind v4 support is out, I’ll wrap up the calendar upgrade and push.Yes. This is fixed in the latest release. Please give it a try and let me know.
Hi,
I had this issue after upgrading to React 19 and Tailwind CSS v4. However, I believe it will also work with just React 19.
I encountered some other problems, but for the calendar specifically, the solution is to reinstall it by running:
npx shadcn@latest add calendarThen, press ‘Y’ when prompted to overwrite.
Hope this will help 😃
Nextjs got updated with react stable , why are still getting the
forceorlegacy depswarning?Getting the same issues as @jasonjos111,
Setup:
Errors:
What is see in my UI components:
what is see when consuming my components:
Not sure how to fix this issue, i have tried setting
npm config set legacy-peer-deps truedidn’t fix anything.The repo: https://github.com/jacobsamo/BuzzTrip/tree/improve-web
run the command : 1 - npm install next@latest react@latest react-dom@latest 2 - npm run-script build 3- npm run start
I believe ShadCN is not stable with the latest NextJs 15 release
I can not add components, but some specific components are throwing random errors
~ button : bunx --bun shadcn@latest add button
~ alert dialog: bunx --bun shadcn@latest add alert-dialog
Whole file is diagnosed with errors
any help?
you will need to make sure your vercel “Build & Development Settings”
Install commandis also set tonpm install --force/--legacy-peer-depslinks to prod example: https://shadcn-10-29-24-04.vercel.app/ https://shadcn-10-29-24-04.vercel.app/dashboard
@shadcn - looks like https://github.com/pacocoursey/cmdk/pull/318 was merged and release was issued when are we going to have this in shadcn release?
Tried out the latest changes:
npx create-next-app@latest my-appnpx shadcn@latest initwith--forceand--legacy-peer-depsAll good on my end. Just a heads up for docs—if someone uses npm/npx, they’ll need to add
--forceor--legacy-peer-depswhenever they install stuff manually, at least for now. Tried it with pnpm too, and it works the same as before, no issues.Let me know if there’s anything else you want me to check!