I am getting this error while installing react-hook-form in my Next.js app.
npm resolution error report
While resolving: carepulse@0.1.0
Found: react@19.0.0-rc-69d4b800-20241021
node_modules/react
react@"19.0.0-rc-69d4b800-20241021" from the root project
Could not resolve dependency:
peer react@"^16.8.0 || ^17 || ^18 || ^19" from react-hook-form@7.53.1
node_modules/react-hook-form
react-hook-form@"*" from the root project
peer react-hook-form@"^7.0.0" from @hookform/resolvers@3.9.0
node_modules/@hookform/resolvers
@hookform/resolvers@"*" from the root project
I tried using
npx shadcn@latest add form --force
and
npx shadcn@latest add form --legacy-peer-deps
But it keeps on showing 'unknown option'
I fixed this issue by downgrading my React version.
I replaced
"react": "19.0.0-rc-69d4b800-20241021",
"react-dom": "19.0.0-rc-69d4b800-20241021"
from my nextJS package.json dependencies with
"react": "^18.2.0",
"react-dom": "^18.2.0"
and did "npm install" to update the dependencies.
The article below was helpful https://nextjs.org/docs/messages/react-version