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]: Peer Dependency Conflicts During Initialization and Adding Components with Next.js 15 #5562

Closed
2 tasks done
Adi-ty opened this issue Oct 24, 2024 · 3 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@Adi-ty
Copy link

Adi-ty commented Oct 24, 2024

Describe the bug

I'm encountering peer dependency conflicts when trying to set up a project with shadcn UI and Next.js (latest v15) as well as when attempting to add components to the project.

Could you please update the initialization and component addition processes to better handle peer dependency issues, especially with React 19 (even in its release candidate state)?

Affected component/components

All

How to reproduce

Steps to Reproduce:

  1. Init
  • Attempt to initialize shadcn UI using the following command:
npx shadcn@latest init
  • The setup reaches the dependency installation and fails with the peer dependencies error.
    Workaround - I was able to complete the initialization by manually running the dependencies installation which were causing error but with --legacy-peer-deps .
  1. Adding Components
  • After resolving the initialization step, I tried adding components using:
npx shadcn@latest add 

image

  • This again failed during dependency installation due to peer dependency conflicts with React 19, producing a similar error:
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! Found: [email protected]
npm ERR! peer react@"^16.8.0 || ^17 || ^18" from various libraries like react-hook-form, @hookform/resolvers, etc.

Workaround - To resolve the issue, I had to downgrade from React 19 (rc) to React 18

The conflicts seem to stem from peer dependencies that expect versions of React from 16.x to 18.x. When using the pre-release React 19, these packages (like react-hook-form, @hookform/resolvers, and others) cause the dependency resolution to fail.

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

OS: Ubuntu 22.04

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@Adi-ty Adi-ty added the bug Something isn't working label Oct 24, 2024
@mazeincoding
Copy link

I have the same issue A workaround is to downgrade React to 18 until they solve the issue. That worked for me.

@TomasioLT
Copy link

I have the same issue A workaround is to downgrade React to 18 until they solve the issue. That worked for me.

For me it is also worked, used next js 14 version.

@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
Projects
None yet
Development

No branches or pull requests

4 participants