React/Typescript專案中新增wagmi viem時如何解決套件不相容問題?
P粉283559033
2023-08-29 11:10:12
<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@">=5.0.4" from @wagmi/chains@1.2.0
- npm ERR! node_modules/viem/node_modules/@wagmi/chains
- npm ERR! @wagmi/chains@"1.2.0" from viem@1.2.12
- npm ERR! node_modules/viem
- npm ERR! viem@"*" from the root project
- npm ERR!
- npm ERR! Could not resolve dependency:
- npm ERR! peerOptional typescript@">=5.0.4" from viem@1.2.12
- npm ERR! node_modules/viem
- npm ERR! viem@"*" from the root project
- npm ERR!
- npm ERR! Conflicting peer dependency: typescript@5.1.6
- npm ERR! node_modules/typescript
- npm ERR! peerOptional typescript@">=5.0.4" from viem@1.2.12
- npm ERR! node_modules/viem
- npm ERR! viem@"*" 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>
viem@1.2.12
和@wagmi/chains@1.2.0
套件需要TypeScript 作為其對等依賴,版本應為>=5.0.4
。當您使用 npm v7 (Node v15 ) 時,將會顯示該警告。>=5.0.4
:因此您可以使用
--legacy-peer-deps
選項
#npm i wagmi viem --legacy-peer-deps