pnpm install:ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies
引言
使用 pnpm install
安裝項目依賴時出現(xiàn):ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies
,在 pnpm github issues 中找到相關(guān)解決方案。
pnpm && npm
一、前言
- 完整日志
ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies . └─┬ koa-views └─┬ consolidate └── ? unmet peer react@^16.13.1: found 18.1.0 hint: If you don't want pnpm to fail on peer dependency issues, set the "strict-peer-dependencies" setting to "false".
- 問題原因:在 npm 3 中,不會再強制安裝
peerDependencies
(對等依賴)中所指定的包,而是通過警告的方式來提示我們。pnpm 會在全局緩存已經(jīng)下載過的依賴包,如果全局緩存的依賴版本與項目package.json
中指定的版本不一致,就會出現(xiàn)這種hint
警告。 pnpm
團隊成員給出的解答:
There are two types of peer deps: optional peer dependencies and non-optional ones. The warnings are only printed for non-optional peer dependencies. If a package works without the peer dependencies, then it should be declared as optional peer dependency. Optional peer dependencies are supported by npm/yarn/pnpm for a long time.
二、處理方案
- 在項目的
package.json
中配置peerDependencyRules
忽略對應(yīng)的警告提示:
{ "pnpm": { "peerDependencyRules": { "ignoreMissing": [ "react" ] } } }
- 在
.npmrc
配置文件中添加strict-peer-dependencies=false
,這意味著將關(guān)閉嚴(yán)格的對等依賴模式。操作命令如下:
npm config set strict-peer-dependencies=false
參考鏈接:https://github.com/pnpm/pnpm/issues/4684
以上就是pnpm install:ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies的詳細(xì)內(nèi)容,更多關(guān)于pnpm install ERR的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
JavaScript中 ?、!和?? 的用法及區(qū)別詳解
在JavaScript中,?., !., 和 ?? 是三個不同的操作符,各自有不同的用途,旨在提高代碼的簡潔性和安全性,尤其是在處理可能的null或undefined值時,下面分別解釋這三個操作符的用法,需要的朋友可以參考下2024-10-10淺談javascript六種數(shù)據(jù)類型以及特殊注意點
這篇文章主要介紹了javascript六種數(shù)據(jù)類型以及特殊注意點,有需要的朋友可以參考一下2013-12-12