使用 react 18 安裝 next-auth 時出現此錯誤
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: gito-auth@0.1.0
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR! react@"18.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.13.1 || ^17" from next-auth@3.29.3
npm ERR! node_modules/next-auth
npm ERR! next-auth@"*" 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\mizzo\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\mizzo\AppData\Local\npm-cache\_logs\2022-04-27T14_07_48_165Z-debug-0.log
是否有任何解決方案可以在不使用 --force 標志的情況下修復它?
uj5u.com熱心網友回復:
看起來你必須降級反應才能安裝下一個身份驗證,我已經嘗試過了,我將反應降級到版本 17.0.2,現在可以安裝下一個身份驗證。如何降級反應如下
remove new version
npm uninstall next react react-dom @types/react @types/react-dom
install old version
npm install next@12.1.2 react@17.0.2 react-dom@17.0.2
npm install -D @types/react@17.0.2 @types/react-dom@17.0.2
我希望安裝下一個身份驗證的錯誤已經解決
uj5u.com熱心網友回復:
這是我解決這個問題的方法:
首先,發生了什么:next-auth 正在尋找 react@"^16.13.1 || ^17",但沒有找到。相反,它正在尋找 [email protected],這是一個較新的版本。出于某種原因不喜歡這個較新的版本,并且您會收到通知(這沒什么大不了的,但他們認為值得停止您的構建)。
一種解決方案:強制安裝next-auth想要的特定版本的react:
npm install [email protected] 這樣做是將你的 react 版本回滾到與 next-auth 兼容的稍舊版本。您不會注意到任何差異,并且在未來的迭代中,希望 next-auth 會更新,所以這會消失。
另一個解決方案:徹底決定不安裝任何舊版本依賴項:
npm install xxxx --legacy-peer-deps 這樣做是忽略此包的舊依賴項。它更全面,可以為您做出很多決定。
uj5u.com熱心網友回復:
這是由開發人員修復的。再次嘗試“npm install --save next-auth”,現在一切正常。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/467152.html
