簡體   English   中英

npm 安裝失敗(無法解析依賴樹)

[英]npm install fails (unable to resolve dependency tree)

試圖減少任何變化的變量並使用我的代碼的新拉動。 它們不是node-module包或package-lock.json 我運行npm install我得到這個錯誤:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react-native-screens@2.15.2
npm ERR! node_modules/react-native-screens
npm ERR!   react-native-screens@"~2.15.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-screens@"^1.0.0 || ^1.0.0-alpha" from react-navigation-drawer@1.4.0
npm ERR! node_modules/react-navigation-drawer
npm ERR!   react-navigation-drawer@"^1.4.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.
npm ERR!
npm ERR! See /Users/myname/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myname/.npm/_logs/2021-05-22T01_16_02_351Z-debug.log

如果我通過--forcenpm install --legacy-peer-deps我會得到一堆文件標記為過時,當我運行npm update時,我會得到同樣的錯誤。 我也嘗試清除 npm 的緩存,但沒有運氣npm cache clean 我不知道為什么會發生這種情況,因為在我的node_modules/react-native-screens下沒有節點模塊文件夾或任何安裝的東西會給出錯誤...它們還沒有 node_modules 文件夾。 是什么原因造成的,我該如何解決?

編輯:我運行npm update -g ,然后npm audit fix ,然后出現錯誤:

code ERESOLVE
ERESOLVE unable to resolve dependency tree

While resolving: Sculp latest app@undefined
Found: react-native-screens@2.15.2
node_modules/react-native-screens
react-native-screens@“~2.15.0” from the root project

所以我跑了expo install react-native-screens並看到它找不到 expo ...檢查了我的文件夾並且我的node_module文件夾丟失了。 就像它從未存在或安裝過一樣。

編輯:我已經嘗試了下面列出的所有方法,它給出了我無法修復的隨機錯誤undefined is not an object (evaluating '_core.ThemeColors.light') ,我已經用谷歌搜索了這個,主要解決方案之一是刪除 npm和 package-lock.json 並重新安裝,但這讓我回到了開始的地方。

這個對我有用:

npm install --save --legacy-peer-deps

Try to copy your src folder and package.json file and initialize another react-native (new) and replace the source the src folder and package.json file and reenter npm install.

您可以在命令行中使用 --force,但稍后您可能必須處理損壞的 react-native 依賴項。 無論如何,還有其他方法可以處理這種損壞的依賴關系。

嘗試這個:

npm 配置設置 legacy-peer-deps true

注意:這將永久設置此標志

一次:

npm install --save --legacy-peer-deps

在以下情況下嘗試:

npm add react-native
expo install (your needed module)

暫無
暫無

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

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