React/Typescript项目中添加wagmi viem时如何解决包不兼容问题?
P粉283559033
P粉283559033 2023-08-29 11:10:12
[React讨论组]
<p>我正在尝试将 wagmi 和 viem 包添加到项目中。我的项目有react-scripts包,我使用的是最新版本5.0.1。 Typescript 运行版本为 4.9.5。但是,当我尝试添加 wagmi 和 viem 时,要求打字稿最低版本为 5.0.4。我该如何解决这个问题?</p> <pre class="brush:php;toolbar:false;">npm i wagmi viem - npm WARN ERESOLVE overriding peer dependency - npm WARN ERESOLVE overriding peer dependency - npm ERR! code ERESOLVE - npm ERR! ERESOLVE could not resolve - npm ERR! - npm ERR! While resolving: viem@1.2.12 - npm ERR! Found: typescript@4.9.5 - npm ERR! node_modules/typescript - npm ERR! peerOptional typescript@&quot;&gt;=5.0.4&quot; from @wagmi/chains@1.2.0 - npm ERR! node_modules/viem/node_modules/@wagmi/chains - npm ERR! @wagmi/chains@&quot;1.2.0&quot; from viem@1.2.12 - npm ERR! node_modules/viem - npm ERR! viem@&quot;*&quot; from the root project - npm ERR! - npm ERR! Could not resolve dependency: - npm ERR! peerOptional typescript@&quot;&gt;=5.0.4&quot; from viem@1.2.12 - npm ERR! node_modules/viem - npm ERR! viem@&quot;*&quot; from the root project - npm ERR! - npm ERR! Conflicting peer dependency: typescript@5.1.6 - npm ERR! node_modules/typescript - npm ERR! peerOptional typescript@&quot;&gt;=5.0.4&quot; from viem@1.2.12 - npm ERR! node_modules/viem - npm ERR! viem@&quot;*&quot; 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.</pre></p>
P粉283559033
P粉283559033

全部回复(1)
P粉917406009

viem@1.2.12@wagmi/chains@1.2.0 包需要 TypeScript 作为其对等依赖,版本应为 >=5.0.4。当您使用 npm v7+(Node v15+) 时,将会显示该警告。

$ npm view viem@1.2.12 peerDependencies
{ typescript: '>=5.0.4' }

$ npm view @wagmi/chains@1.2.0 peerDependencies
{ typescript: '>=5.0.4' }
  1. 将 TypeScript 升级到版本 >=5.0.4
npm i typescript@^5.0.4 -D
  1. 请参阅在peerDependencies中允许使用TypeScript 5+以及宣布推出 TypeScript 5.0

因此您可以使用--legacy-peer-deps选项

npm i wagmi viem --legacy-peer-deps

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号