PNPM同行依赖性自动安装
如何(或在哪个文件上)设置为true以进行自动安装依赖关系?
我的终端错误:
提示:如果您希望自动安装同伴依赖关系,请设置 “自动安装者”设置为“ true”。提示:如果您不想要 pnpm在同行依赖性问题上失败,设置 “严格依赖性”设置为“ false”。
auto-install-peers = true
How (or on which file) to set true to do auto install dependencies ?
my terminal error:
hint: If you want peer dependencies to be automatically installed, set
the "auto-install-peers" setting to "true". hint: If you don't want
pnpm to fail on peer dependency issues, set the
"strict-peer-dependencies" setting to "false".
auto-install-peers = true
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(6)
PNPM使用NPM的配置格式。因此,您应该以NPM的方式设置配置:
注意:上面命令使用默认配置位置,该位置存储本地用户帐户的设置(at
〜/.NPMRC < /code> for Linux或以
%的userProfile%\。npmrc
for Windows)。要将设置存储在项目中的设置中.npmrc
可以检查到版本控制的文件,您可以使用@zoltankochan指出的方法,或等效地附加- 位置project < /代码>到命令:
pnpm uses npm's configuration formats. Hence, you should set configuration the same way you would for npm:
Note: The above command uses the default config location which stores the setting for the local user account (at
~/.npmrc
for linux, or at%USERPROFILE%\.npmrc
for Windows). To store the setting inside your project in a.npmrc
file that can be checked in to version control, you can use the method pointed out by @ZoltanKochan, or equivalently append--location project
to the command:您需要在项目的根部使用以下内容创建
.npmrc
:MRMASHAL的答案也将起作用,但仅适用于本地。因此,当其他人获取您的存储库时,他们将不会自动安装同行。
You need to create a
.npmrc
at the root of your project with the following content:The answer from mrmashal will work also but only for you locally. So, when someone else fetches your repository, they will not have the peers automatically installed.
来自V7的NPM自动安装,PNPM不会
npm 启动 v7 。安装对等依赖项会自动 htttps:// github。 com/npm/rfcs/blob/main/ainted/0025-install-peer-deps.md 。
pnpm不会自动这样做。即使在这个阶段。
https://github.com/pnpm/pnpm/discussions/3995#discussioncomment-1893230
NPM仅使用
.npmrc
做同样的方式和带有
。 NPMRC
和不是自动
是所涉及的开发人员的选择。有些人是为了而不是。 ( ref1 , ref2。
)
/pnpm/pnpm/descorgions/3995# deledcomponment 最好的方法。因为它为所有消费项目和存储库的开发人员创造了一致性。相同的配置。
因此,用简化的术语,如果您有一些需要对等方的软件包,只需添加配置。您有一个不错的警告,可以提醒您,以防有
peer依赖性
的软件包。https://github.com.com.com.com.com.com/pnpm/pnpm/pnpm/pnpm/discussions/399995,9952-752-2799999979999999799799799.7999999999999799979979.752-2-2-279979972
是否存在
- 自动安装式peers
arg存在吗? (否)没有
- 自动安装式同行
arg。可以在此处检查功能询问此处 https://github.com/pnpm/pnpm/pnpm/5284 <5284 < /a>
否认。
而为什么可以理解。
.npmrc
更好地保持一致性。因此,PeoplePNPM install
始终可以工作。不要忘记任何事情。使用install-peerDeps
https://www.npmjs.com/package/package/package/install-peern-peer-peer-peer-peer-peern-peern-peern-peern-peern-peern-peern-peern-peern-peern-peern-peerndeps
-peerDeps 支持PNPM。
例如,在
eSlint-config-airbnb
中提到该工具。示例:
软件包将自动将依赖项添加到
package.json
in依赖项
或devDepentencies
取决于使用的标志。npm from v7 does auto-install, pnpm doesn't
npm starting from v7. Does install Peer Dependencies automatically https://github.com/npm/rfcs/blob/main/implemented/0025-install-peer-deps.md.
pnpm doesn't do it automatically. Even at this stage.
https://github.com/pnpm/pnpm/discussions/3995#discussioncomment-1893230
npm does the same way only with
.npmrc
And the with
.npmrc
andnot automatic
was a choice by the developers involved. There are those who were for and who weren't. (ref1, ref2).npmrc
To do it you have to create a
.npmrc
file and add:This is the best way. Because it creates consistency for all developers consuming the project and repo. Same config.
So in simplified terms, if you have some packages that require peers just add the config. You have a nice warning that reminds you in case there are packages with
peer-dependencies
.https://github.com/pnpm/pnpm/discussions/3995#discussioncomment-2797582
Does an
--auto-install-peers
arg exists ? (No)There is no
--auto-install-peers
arg.Can check here the feature ask here https://github.com/pnpm/pnpm/issues/5284
Denied.
And the why is understandable.
.npmrc
is better for consistency. So that peoplepnpm install
and it always works the same. No forgetting anything.Using install-peerdeps
https://www.npmjs.com/package/install-peerdeps
install-peerdeps
supports pnpm.The tool is mentioned in
eslint-config-airbnb
for example.Example:
The package will automatically add the dependencies to
package.json
independencies
ordevDependencies
depending on the used flag.通过运行删除节点模块:
然后再次运行:
Remove the node modules by running:
Then again run:
从版本7开始,
pnpm
默认情况下支持自动安装的同行依赖关系。要启用/禁用自动安装的同行依赖项,您可以使用以下命令设置/UNSET
自动安装式peer
。上面的命令将在全局.NPMRC文件中全球设置此选项。
要在本地进行,请添加
-location = Project
。另外,您可以手动创建/编辑
.npmrc
文件。设置
自动安装式同行
选项之后,您可能需要删除node_modules
目录和pnpm-lock.yaml
file> file> file file codepnpm i-羞辱
。原始答案
我必须使用
auto-install-peers = true
在项目的根部创建.npmrc
,然后删除pnpm-lock.yaml 文件并运行
pnpm i-嘲讽
。Starting from version 7,
pnpm
supports auto-installing peer dependencies by default.To enable/disable auto-installing peer dependencies, you can set/unset
auto-install-peers
using the following command.The above command will set this option globally in global .npmrc file.
To do it locally, add
--location=project
.Also, you can manually create/edit
.npmrc
file.After setting
auto-install-peers
option, you might need to deletenode_modules
directory, andpnpm-lock.yaml
file and then runpnpm i --shamefully-hoist
.Original answer
I had to create
.npmrc
at the root of the project withauto-install-peers=true
, then delete thepnpm-lock.yaml
file and runpnpm i --shamefully-hoist
.在项目的根部修改或创建一个.NPMRC文件,然后插入以下指令,该指令指示PNPM自动安装同行依赖关系:
然后进行PNPM安装或PNPM安装 - FORCE-force
Modify or create a .npmrc file at the root of your project and insert the following instruction, which instructs pnpm to auto-install peer dependencies:
Then do a pnpm install or pnpm install --force