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:

  1. Update @radix-ui/react-icons peer dependencies to include React 19
  2. Add a note in the documentation about React 19 compatibility
  3. 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
  1. During the setup, select ‘yes’ for App Router and other default options

  2. Navigate to the project directory: bash cd my-app

  3. Try to initialize shadcn-ui: bash npx shadcn@latest init

  4. Select configuration options:

    • Style: New York
    • Base color: Neutral
    • CSS variables: Yes
  5. 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

Most upvoted comments

You can also use: npm config set legacy-peer-deps true

Solution is to install react@18 and react-dom@18. It’ll temporarily solve the issue.

Use Nextjs 14

npx create-next-app@14

I found a solution. Use pnpm package manager

you can use overrides for a temporary fix.

"overrides": {
	"react": "$react",
	"react-dom": "$react-dom"
}

[!WARNING]
This is just 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.

image

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-fns using npm install date-fns, and that gave me an error, I fixed it by doing this: uninstalling it, and then running npx shadcn@latest add calendar and that installed the correct version of date-fns.

What is actually required for ShadCN to support React 19? I’ll start a list:

What is the output/errors you all are getting?

This is the full error:

I decided to try in a fresh nextjs project.

npx create-next-app test-shadcn

Then install shadcn

npx shadcn@latest init

The above command throws me this error:

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 error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: test-shadcn@0.1.0
npm error Found: react@19.0.0-rc-69d4b800-20241021
npm error node_modules/react
npm error   react@"19.0.0-rc-69d4b800-20241021" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@"^16.x || ^17.x || ^18.x" from @radix-ui/react-icons@1.3.0
npm error node_modules/@radix-ui/react-icons
npm error   @radix-ui/react-icons@"^1.3.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.

As temporal fix, it worked to execute this command

I need this urgently, is there any other solution for this ?

Getting the same issues as @jasonjos111,

@jasonjos111 this command doesn’t seem to work on workspaces: npm config set legacy-peer-deps true Screenshot 2024-11-11 at 8 19 15 PM this is what i get if i run this command inside my NextJs project inside a monorepo well if i run this command: npm config set legacy-peer-deps true in the root of my monorepo Screenshot 2024-11-11 at 8 20 18 PM i don’t get any output- meaning it works. But the error is still there: Screenshot 2024-11-11 at 8 20 45 PM

Setup:

  • Package manager: bun v1.1.36
  • system i am expericing the issue on: MacOS 14.5 & Window 11
  • React version: react@19.0.0-rc.1, react-dom@19.0.0-rc.1

Errors:

What is see in my UI components:

Type ‘ForwardRefExoticComponent<AccordionItemProps & RefAttributes<HTMLDivElement>>’ does not satisfy the constraint ‘keyof IntrinsicElements | ForwardRefExoticComponent<any> | (new (props: any) => Component<any, {}, any>) | ((props: any) => ReactNode)’. Type ‘ForwardRefExoticComponent<AccordionItemProps & RefAttributes<HTMLDivElement>>’ is not assignable to type ‘ForwardRefExoticComponent<any>’. Type ‘React.ReactNode’ is not assignable to type ‘import(“/Users/jacob/Documents/GitHub/BuzzTrip/apps/web/node_modules/@types/react/index”).ReactNode’. Type ‘bigint’ is not assignable to type ‘ReactNode’. what is see when consuming my components:

‘Button’ cannot be used as a JSX component. Its type ‘ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>’ is not a valid JSX element type. Type ‘ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>’ is not assignable to type ‘(props: any, deprecatedLegacyContext?: any) => ReactNode’. Type ‘import(“/Users/jacob/Documents/GitHub/BuzzTrip/apps/web/node_modules/@types/react/index”).ReactNode’ is not assignable to type ‘React.ReactNode’. Type ‘ReactElement<unknown, string | JSXElementConstructor<any>>’ is not assignable to type ‘ReactNode’. Property ‘children’ is missing in type ‘ReactElement<unknown, string | JSXElementConstructor<any>>’ but required in type ‘ReactPortal’. Not sure how to fix this issue, i have tried setting npm config set legacy-peer-deps true didn’t fix anything.

The repo: https://github.com/jacobsamo/BuzzTrip/tree/improve-web

I’m still running into this issue w/ bun

bun v1.2.3-canary.29
react@^18.3.1
@types/react@18.3.3
Type 'ForwardRefExoticComponent<SlotProps & RefAttributes<HTMLElement>>' does not satisfy the constraint 'keyof IntrinsicElements | ForwardRefExoticComponent<any> | (new (props: any) => Component<any, {}, any>) | ((props: any, deprecatedLegacyContext?: any) => ReactNode)'.
  Type 'ForwardRefExoticComponent<SlotProps & RefAttributes<HTMLElement>>' is not assignable to type 'ForwardRefExoticComponent<any>'.
    Type 'React.ReactNode' is not assignable to type 'import(".../node_modules/@types/react/index").ReactNode'.
      Type 'bigint' is not assignable to type 'ReactNode'.

and when using <FormControl>:

Type '{ children: Element; }' has no properties in common with type 'IntrinsicAttributes & RefAttributes<never>'.

I think one thing that can be done is to use --legacy-peer-deps

try to run in the command prompt npm install shadcn --legacy-peer-deps

I 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!

"overrides": {
    "react-is": "$react-is",
    "@types/react": "npm:types-react@19.0.0-rc.1",
    "@types/react-dom": "$@types/react-dom-rc.1"
  },
"resolutions": {
    "@types/react": "npm:types-react@19.0.0-rc.1",
    "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1"
  }

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.

image

@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.

Update: https://ui.shadcn.com/docs/react-19. Please take a look and let me know. Thank you.

wrong link in the shadcn docs https://ui.shadcn.com/docs/installation/next

Leads to a 404 Screenshot 2024-10-29 at 5 44 33 PM

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.json react version must less that 18; and also react dom less 18;

"devDependencies": {
   "@types/node": "^20", 
   "@types/react": "^18",  <<here
   "@types/react-dom": "^18", <<
   "eslint": "^8",

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-icons package.

Here’s what I did:

  1. Created a repo with npx shadcn/ui@latest init, using New York as the style and including @radix-ui/react-icons.
  2. Added some components with npx shadcn/ui@latest add ... and made sure to use some icons from @radix-ui/react-icons.
  3. Verified everything ran fine in Next.js 14.
  4. Ran the codemod to upgrade: npx @next/codemod@canary upgrade latest.
  5. Placed an @radix-ui/react-icons icon 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:

  • Next.js: 15.0.1
  • React: 19.0.0-rc-69d4b800-20241021
  • React DOM: 19.0.0-rc-69d4b800-20241021
  • @radix-ui/react-icons: ^1.3.0
  • Tailwind CSS: ^3.4.1
  • TypeScript: ^5 package manager: pnpm 9.9.0
"pnpm": {
    "overrides": {
      "@types/react": "npm:types-react@19.0.0-rc.1",
      "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1"
    }
  }

Feel 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 init failing. 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 calendar

Then, press ‘Y’ when prompted to overwrite.

Hope this will help 😃

Nextjs got updated with react stable , why are still getting the force or legacy deps warning?

Getting the same issues as @jasonjos111,

@jasonjos111 this command doesn’t seem to work on workspaces: npm config set legacy-peer-deps true Screenshot 2024-11-11 at 8 19 15 PM

this is what i get if i run this command inside my NextJs project inside a monorepo

well if i run this command: npm config set legacy-peer-deps true in the root of my monorepo Screenshot 2024-11-11 at 8 20 18 PM

i don’t get any output- meaning it works.

But the error is still there: Screenshot 2024-11-11 at 8 20 45 PM

Setup:

  • Package manager: bun v1.1.36
  • system i am expericing the issue on: MacOS 14.5 & Window 11
  • React version: react@19.0.0-rc.1, react-dom@19.0.0-rc.1

Errors:

What is see in my UI components:

Type 'ForwardRefExoticComponent<AccordionItemProps & RefAttributes<HTMLDivElement>>' does not satisfy the constraint 'keyof IntrinsicElements | ForwardRefExoticComponent<any> | (new (props: any) => Component<any, {}, any>) | ((props: any) => ReactNode)'.
  Type 'ForwardRefExoticComponent<AccordionItemProps & RefAttributes<HTMLDivElement>>' is not assignable to type 'ForwardRefExoticComponent<any>'.
    Type 'React.ReactNode' is not assignable to type 'import("/Users/jacob/Documents/GitHub/BuzzTrip/apps/web/node_modules/@types/react/index").ReactNode'.
      Type 'bigint' is not assignable to type 'ReactNode'.

what is see when consuming my components:

'Button' cannot be used as a JSX component.
  Its type 'ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>' is not a valid JSX element type.
    Type 'ForwardRefExoticComponent<ButtonProps & RefAttributes<HTMLButtonElement>>' is not assignable to type '(props: any, deprecatedLegacyContext?: any) => ReactNode'.
      Type 'import("/Users/jacob/Documents/GitHub/BuzzTrip/apps/web/node_modules/@types/react/index").ReactNode' is not assignable to type 'React.ReactNode'.
        Type 'ReactElement<unknown, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
          Property 'children' is missing in type 'ReactElement<unknown, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.

Not sure how to fix this issue, i have tried setting npm config set legacy-peer-deps true didn’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 Screenshot 2024-11-11 at 6 43 23 PM

Screenshot 2024-11-11 at 6 43 41 PM

~ alert dialog: bunx --bun shadcn@latest add alert-dialog Screenshot 2024-11-11 at 6 44 06 PM

Whole file is diagnosed with errors

any help?

i add shad cn components with --legacy-peer-deps and in development it works very well as well as when i build it locally it used to work as it expected but when i try to deploy it on vercel it’s giving me the error

photo_2024-10-31_12-33-33

you will need to make sure your vercel “Build & Development Settings” Install command is also set to npm install --force/--legacy-peer-deps

links to prod example: https://shadcn-10-29-24-04.vercel.app/ https://shadcn-10-29-24-04.vercel.app/dashboard

image

@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?

Update: https://ui.shadcn.com/docs/react-19. Please take a look and let me know. Thank you.

Tried out the latest changes:

  1. npx create-next-app@latest my-app
  2. npx shadcn@latest init with --force and --legacy-peer-deps

All good on my end. Just a heads up for docs—if someone uses npm/npx, they’ll need to add --force or --legacy-peer-deps whenever 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!