簡體   English   中英

無法解決依賴關系

[英]Could not resolve dependency

我一直在嘗試下載一個模板來開始定制它。 下載后,應該使用npm installyarn install安裝所有本地依賴項。 我已經完成了這兩項工作,並且兩次都遇到了相同的錯誤。 此外,按照錯誤消息中的建議,我已嘗試將相同的命令與--force--legacy-peer-deps一起使用。 我發現了一個 GitHub 問題,討論了這個精確的問題和其他一些堆棧溢出線程。 我已經嘗試了我遇到的所有事情,但它不起作用。 此外,我已經安裝了推薦版本的節點,所以這也不是問題,正如另一個線程中所建議的那樣。

可以在下面看到錯誤消息。

While resolving: @mui/material@5.2.0
npm ERR! Found: @emotion/react@11.4.1
npm ERR! node_modules/@emotion/react
npm ERR!   @emotion/react@"11.4.1" from the root project
npm ERR!   peer @emotion/react@"^11.0.0-rc.0" from @emotion/styled@11.3.0
npm ERR!   node_modules/@emotion/styled
npm ERR!     @emotion/styled@"11.3.0" from the root project
npm ERR!     peerOptional @emotion/styled@"^11.3.0" from @mui/material@5.2.0
npm ERR!     node_modules/@mui/material
npm ERR!       @mui/material@"5.2.0" from the root project
npm ERR!       1 more (@mui/icons-material)
npm ERR!     1 more (@mui/styled-engine)
npm ERR!   1 more (@mui/styled-engine)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional @emotion/react@"^11.5.0" from @mui/material@5.2.0
npm ERR! node_modules/@mui/material
npm ERR!   @mui/material@"5.2.0" from the root project
npm ERR!   peer @mui/material@"^5.0.0" from @mui/icons-material@5.2.0
npm ERR!   node_modules/@mui/icons-material
npm ERR!     @mui/icons-material@"5.2.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: @emotion/react@11.7.1
npm ERR! node_modules/@emotion/react
npm ERR!   peerOptional @emotion/react@"^11.5.0" from @mui/material@5.2.0
npm ERR!   node_modules/@mui/material
npm ERR!     @mui/material@"5.2.0" from the root project
npm ERR!     peer @mui/material@"^5.0.0" from @mui/icons-material@5.2.0
npm ERR!     node_modules/@mui/icons-material
npm ERR!       @mui/icons-material@"5.2.0" 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.

模板: https://www.creative-tim.com/product/material-dashboard-react?ref=readme-mdr#

GitHub 問題: https://github.com/creativetimofficial/material-dashboard-react/issues/171

提前致謝。

通過進入我的項目的 package.json 並將@emotion/react從 11.4.1 更改為 11.5.0 解決了這個問題,因為它說這就是發生依賴問題的地方。

從 package.json 文件升級您的版本並再次運行“npm install”命令

當我不在我的 react 應用程序的文件夾中時,我收到了這個錯誤。 cd進去應該很好,但我很肯定你現在找到了這個答案,或者像我一樣偶然發現了它。 最好的祝願

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM