簡體   English   中英

覆蓋對等依賴項時出錯 - npm 安裝 reactstrap

[英]Error overriding peer dependency - npm install reactstrap

"@popperjs/core": "^2.6.0",
"@testing-/jest-dom": "^5.11.9",
"@testing-/react": "^11.2.3",
"@testing-/user-event": "^12.6.2",
"bootstrap": "^4.6.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"react-transition-group": "^4.4.1",

我在 package.json 文件中的依賴項版本。

G:\Projects\React\confusion> npm 安裝 --save reactstrap

npm WARN ERESOLVE 重寫對等依賴
npm WARN 發現:react@17.0.1
npm 警告節點模塊/反應
npm WARN peer react@" " from @testing-/react@11.2.3
npm 警告 node_modules/@testing-/react
npm WARN @testing-/react@"^11.2.3" 來自根項目
npm 警告 3 個以上(react-dom、根項目、reactstrap)
npm 警告
npm WARN 無法解析依賴項:
npm WARN peer react@"0.14.x || ^15.0.0 || ^16.0.0" from react-popper@1.3.7
npm 警告 node_modules/react-popper
npm 警告 react-popper@"^1.3.6" 來自 reactstrap@8.9.0
npm 警告 node_modules/reactstrap
npm 錯誤! 代碼 ERESOLVE
npm 錯誤! ERESOLVE 無法解析依賴樹
npm 錯誤:npm 錯誤。 成立。 反應@17.0.1
npm 錯誤! 節點模塊/反應
npm 錯誤! 來自@testing-/react@11.2.3 的peer react@" "
npm 錯誤! node_modules/@testing-/反應
npm 錯誤。 來自根項目的@testing-/react@"^11.2.3"
npm 錯誤。 來自 react-dom@17.0.1 的 peer react@"17.0.1"
npm 錯誤! node_modules/反應-dom
npm 錯誤! 來自@testing-/react@11.2.3 的 peer react-dom@" "
npm 錯誤! node_modules/@testing-/反應
npm 錯誤。 來自根項目的@testing-/react@"^11.2.3"
npm 錯誤。 來自根項目的 react-dom@"^17.0.1"
npm 錯誤! 1個以上(reactstrap)
npm ERR,還有 2 個(根項目,reactstrap)
npm 錯誤!
npm 錯誤:無法解析依賴項:
npm 錯誤。 peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" 來自 create-react-context@0.3.0
npm 錯誤! node_modules/react-popper/node_modules/create-react-context
npm 錯誤。 create-react-context@"^0.3.0" 來自 react-popper@1.3.7
npm 錯誤! node_modules/反應波普爾
npm 錯誤! node_modules/reactstrap
npm 錯誤! 來自根項目的reactstrap@" "
npm 錯誤,npm 錯誤! 修復上游依賴沖突,或者重試
npm ERR,此命令帶 --force 或 --legacy-peer-deps
npm 錯誤。 接受不正確(並且可能損壞)的依賴項解析。

在你的package.json中嘗試這樣的事情

  "engines": {
    "npm": ">=8.7.0"
  },
  "overrides": {
    "react": "$react"
  }

這將強制反應為所有依賴項(& deps of deps)的"dependencies"中定義的版本。 您需要“最近的”npm,因為它在某些版本中存在錯誤(我有 8.3.0 並且覆蓋不起作用)。 8.7.0 似乎沒問題!

請參閱https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

這是因為 npm 版本 7 中的更改。請參閱此處的重大更改部分 您可以使用錯誤告訴您在底部使用的標志來修復它: npm i reactstrap --legacy-peer-deps 如果您的其他依賴項之一已經將 reactstrap 作為對等依賴項,您可能根本不需要安裝它(您可以使用npm ls reactstrap進行檢查),因為 v7.7 中的更改。

要解決 REACT_SPRING 安裝問題,請嘗試

npm install  --force

然后

npm audit fix --force

暫無
暫無

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

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