我在 Next.js 应用中安装react-hook-form时出现此错误。
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
我尝试使用
npx shadcn@latest add form --force
and
npx shadcn@latest add form --legacy-peer-deps
但它一直显示“未知选项”
最佳答案
1
我通过降级我的 React 版本解决了这个问题。
我更换了
"react": "19.0.0-rc-69d4b800-20241021",
"react-dom": "19.0.0-rc-69d4b800-20241021"
从我的 nextJS package.json 依赖项
"react": "^18.2.0",
"react-dom": "^18.2.0"
并执行“npm install”来更新依赖项。
下面的文章很有帮助
|
|