reactjs 我是否解决了package.jason文件错误?

i5desfxk  于 2023-04-20  发布在  React
关注(0)|答案(3)|浏览(160)

为什么我有下面的错误

PS C:\Users\USER\Desktop\Shareme\shareme_frontend> npm install @sanity/client @sanity/image-url react-google-login react-icons react-loader-spinner react-masonry-css react-router-dom uuid
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: shareme_frontend@0.1.0
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16 || ^17" from react-google-login@5.2.2
npm ERR! node_modules/react-google-login
npm ERR!   react-google-login@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\USER\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Local\npm-cache\_logs\2022-06-29T15_11_18_949Z-debug-0.log
amrnrhlw

amrnrhlw1#

react-google-login没有更新到最新的react v18。要么等待更新,降级react到v17,要么使用--force标志。

npm i react-google-login --force

请注意,使用--force并不能保证此软件包将与react的v18一起工作。

jvidinwx

jvidinwx2#

react-google-login@5.2.2与react 18版本不兼容,因为5.2.2是一年前根据npm page.发布的
它仍然在寻找17 / 16的react版本。下面的错误块会告诉你这一点:

npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16 || ^17" from react-google-login@5.2.2

您可以通过以下方式为该特定项目降级react:
1.删除node_modules
1.运行npm cache clean
1.手动更新package.json以将react版本更改为17
1.运行npm install

ss2ws0br

ss2ws0br3#

您可以使用此命令通过命令行进行安装:

npm install @sanity/client @sanity/image-url react-google-login react-icons react-loader-spinner react-masonry-css react-router-dom uui --force

相关问题