PNPM同行依赖性自动安装

发布于 2025-02-03 13:51:26 字数 305 浏览 4 评论 0原文

如何(或在哪个文件上)设置为true以进行自动安装依赖关系?

我的终端错误:

“我的终端错误”

提示:如果您希望自动安装同伴依赖关系,请设置 “自动安装者”设置为“ true”。提示:如果您不想要 pnpm在同行依赖性问题上失败,设置 “严格依赖性”设置为“ false”。

auto-install-peers = true

How (or on which file) to set true to do auto install dependencies ?

my terminal error:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

羁绊已千年 2025-02-10 13:51:26

PNPM使用NPM的配置格式。因此,您应该以NPM的方式设置配置:

pnpm config set auto-install-peers true

注意:上面命令使用默认配置位置,该位置存储本地用户帐户的设置(at 〜/.NPMRC < /code> for Linux或以%的userProfile%\。npmrc for Windows)。要将设置存储在项目中的设置中.npmrc可以检查到版本控制的文件,您可以使用@zoltankochan指出的方法,或等效地附加- 位置project < /代码>到命令:

pnpm config set auto-install-peers true --location project

pnpm uses npm's configuration formats. Hence, you should set configuration the same way you would for npm:

pnpm config set auto-install-peers true

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:

pnpm config set auto-install-peers true --location project
谜泪 2025-02-10 13:51:26

您需要在项目的根部使用以下内容创建.npmrc

auto-install-peers=true

MRMASHAL的答案也将起作用,但仅适用于本地。因此,当其他人获取您的存储库时,他们将不会自动安装同行。

You need to create a .npmrc at the root of your project with the following content:

auto-install-peers=true

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.

内心荒芜 2025-02-10 13:51:26

来自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做同样的方式

auto-install-peers = true

自动安装 - peers = true现在使PNPM的工作方式与NPM V7相同。来自pnpm v7.1.3(

和带有。 NPMRC不是自动是所涉及的开发人员的选择。有些人是为了而不是。 ( ref1 ref2

auto-install-peers = true

/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 = true现在使PNPM的工作方式与NPM V7相同。来自PNPM v7.1.3

是否存在- 自动安装式peers arg存在吗? (否)

没有- 自动安装式同行 arg。

可以在此处检查功能询问此处 https://github.com/pnpm/pnpm/pnpm/5284 <5284 < /a>

否认。

而为什么可以理解。 .npmrc更好地保持一致性。因此,People PNPM install始终可以工作。不要忘记任何事情。

使用install-peerDeps

我建议使用.npmrc。 - &gt;本国的。直截了当。

注意:您可以考虑使用此工具。如果您陷入了一些pnpm错误(ex: 1 ,依赖性处理。许多问题是开放的。我会选择.pnpmrc first。如果有问题。我会使用此工具。

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中提到该工具。

示例:

npx install-peerdeps --pnpm <your-package>

# or

npx install-peerdeps -P <your-package>

# as dev dep
npx install-peerdeps -P -D <your-package>

# Peers only
npx install-peerdeps -P -D --only-peers <your-package>
# or
npx install-peerdeps -P -D -o <your-package>

软件包将自动将依赖项添加到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

auto-install-peers = true

auto-install-peers=true now makes pnpm work the same way as npm v7. From pnpm v7.1.3 (ref)

And the with .npmrc and not 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:

auto-install-peers = true

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

auto-install-peers=true now makes pnpm work the same way as npm v7. From pnpm v7.1.3

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 people pnpm install and it always works the same. No forgetting anything.

Using install-peerdeps

I advise using .npmrc. -> Native. straight forward.

Note: you may consider this tool. If you fall into some of pnpm bugs (ex: 1, ) and inconsistencies with peer-dependencies handling. Many issues are open. I would go with .pnpmrc first. If any issues. I would use this tool.

https://www.npmjs.com/package/install-peerdeps

install-peerdeps supports pnpm.

The tool is mentioned in eslint-config-airbnb for example.

Example:

npx install-peerdeps --pnpm <your-package>

# or

npx install-peerdeps -P <your-package>

# as dev dep
npx install-peerdeps -P -D <your-package>

# Peers only
npx install-peerdeps -P -D --only-peers <your-package>
# or
npx install-peerdeps -P -D -o <your-package>

The package will automatically add the dependencies to package.json in dependencies or devDependencies depending on the used flag.

揽月 2025-02-10 13:51:26

通过运行删除节点模块:

rm -rf node_modules

然后再次运行:

pnpm install

Remove the node modules by running:

rm -rf node_modules

Then again run:

pnpm install
临走之时 2025-02-10 13:51:26

从版本7开始,pnpm默认情况下支持自动安装的同行依赖关系。

要启用/禁用自动安装的同行依赖项,您可以使用以下命令设置/UNSET 自动安装式peer

pnpm config set auto-install-peers [true/false]

上面的命令将在全局.NPMRC文件中全球设置此选项。

要在本地进行,请添加-location = Project

另外,您可以手动创建/编辑.npmrc文件。

设置自动安装式同行选项之后,您可能需要删除node_modules目录和pnpm-lock.yaml file> file> file file code pnpm 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.

pnpm config set auto-install-peers [true/false]

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 delete node_modules directory, and pnpm-lock.yaml file and then run pnpm i --shamefully-hoist.

Original answer

I had to create .npmrc at the root of the project with auto-install-peers=true, then delete the pnpm-lock.yaml file and run pnpm i --shamefully-hoist.

羁拥 2025-02-10 13:51:26

在项目的根部修改或创建一个.NPMRC文件,然后插入以下指令,该指令指示PNPM自动安装同行依赖关系:

auto-install-peers=true

然后进行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:

auto-install-peers=true

Then do a pnpm install or pnpm install --force

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文