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

Add react-dom and react-router-dom deps to the user's package.json #2408

Open
2 of 6 tasks
infomiho opened this issue Dec 10, 2024 · 1 comment
Open
2 of 6 tasks

Add react-dom and react-router-dom deps to the user's package.json #2408

infomiho opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels
shouldfix We should do/fix this at some point

Comments

@infomiho
Copy link
Contributor

infomiho commented Dec 10, 2024

Some users when installing deps e.g. react-hot-toast receive this error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: rrtest@undefined
npm ERR! Found: react@18.3.1
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!   peer react@">=16" from react-hot-toast@2.4.1
npm ERR!   node_modules/react-hot-toast
npm ERR!     react-hot-toast@"*" from the root project
npm ERR!   1 more (wasp)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^19.0.0" from react-dom@19.0.0
npm ERR! node_modules/react-dom
npm ERR!   peer react-dom@">=16" from react-hot-toast@2.4.1
npm ERR!   node_modules/react-hot-toast
npm ERR!     react-hot-toast@"*" from the root project

Let's take a closer look:

  • peer react@">=16" from react-hot-toast@2.4.1
    • says that react-hot-toast will be satisfied with any version of React above and including React 16.
    • We specified react@^18.2.0 in the user's package.json
    • so npm goes with that version.
    • All good ✅
  • peer react-dom@">=16" from react-hot-toast@2.4.1
    • says that react-hot-toast will be satisfied with any version of React DOM above and including React DOM 16.
    • So, npm goes for the latest version since we don't specify react-dom in the user's package.json file.
    • Since React 19 came out, the latest means React DOM 19 which then tries to pull React 19.
    • This conflicts with our React 18 dep 🔴

A similar thing happened with React Router 7 being released, so we should also put react-router-dom dep in the user land package.json.

How to solve this

  • I propose we add the react-dom and react-router-dom in the user's package.json in all the templates.
  • Also, let's ping any community template authors to do the same.
  • We can add package.json validation rules in the next Wasp version to validate if users have these deps in their package.json for any users. that have an existing project.
@infomiho infomiho added the shouldfix We should do/fix this at some point label Dec 10, 2024
@Martinsos
Copy link
Member

Awesome @infomiho , sounds like a good plan!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shouldfix We should do/fix this at some point
Projects
None yet
Development

No branches or pull requests

2 participants