npm错误!冲突的对等依赖关系:18.0.0时的React

khbbv19g  于 2023-01-31  发布在  React
关注(0)|答案(4)|浏览(394)

我似乎不明白为什么会发生这个错误。我正在尝试创建一个新的react-native项目,另一个已经创建,并在不同的目录中,这是不是低于其他安装目录树。我已经卸载并重新安装了节点,我认为可能是问题。我使用brew医生和删除以前安装的homebrew,我在usr/local/includes
我试图得到一个干净的安装React Native,但它似乎我不能这样做。
谢谢你的帮助。
这是我一直收到的错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native@0.67.4
npm ERR! node_modules/react-native
npm ERR!   peer react-native@"*" from @react-native-community/cli@6.4.0
npm ERR!   node_modules/@react-native-community/cli
npm ERR!     @react-native-community/cli@"^6.0.0" from react-native@0.67.4
npm ERR!   react-native@"0.69.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! react-native@"0.69.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@18.0.0
npm ERR! node_modules/react
npm ERR!   peer react@"18.0.0" from react-native@0.69.1
npm ERR!   node_modules/react-native
npm ERR!     react-native@"0.69.1" 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 /Users/Name/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Name/.npm/_logs/2022-07-14T06_15_09_791Z-debug-0.log
z0qdvdin

z0qdvdin1#

我有和你一样的问题。为了修复错误。
打开cli,然后键入:open /Users/Name/.npm然后删除文件夹_缓存、_日志、_npx。
删除这些文件夹后,我可以安装新的React Native项目。

svmlkihl

svmlkihl2#

将--legacy-peer-deps添加到命令末尾

--legacy-peer-deps
s3fp2yjn

s3fp2yjn3#

步骤1:打开/用户/名称/.npm
步骤2:要在Mac上查看隐藏文件夹,请按Cmd + Shift + .(dot)
步骤3:删除文件夹_cacache,_logs,_npx

vlju58qv

vlju58qv4#

对于Windows用户:

打开C:\Users\%username%\AppData\Local\npm-cache,然后删除文件夹_cacache_logs_npx
删除那些文件夹后,我可以在我的Windows PC上安装一个新的React Native项目。

相关问题