使用命令在 npm 中保存对等依赖项 [英] Save peer dependencies in npm with a command

查看:72
本文介绍了使用命令在 npm 中保存对等依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 npm 实现这一目标?目前我手动执行此操作,使用与 npm install --save 类似的方法会很好

Is there a way to achieve that using npm ? Currently I do this manually, would be nice to use similar approach as with npm install --save

我发现了一些旧的讨论和提交,但似乎没有成功:

I found some old discussion and commits but it seems it didn't make it:

https://github.com/npm/npm/pull/3994

推荐答案

据我所知,你不能.只需将其安装为常规依赖项(生产或其他方式,就像安装需要对等依赖项的包一样).

As far as I can tell, you can't. Just install it as a regular dependency (production or otherwise, just like the package requiring the peer dependency is installed as).

即使您手动将条目添加到 peerDependenciesnpm audit 也将无法识别该包并告诉您安装它.

Even if you manually add the entry to peerDependencies an npm audit is going to fail to recognize the package and tell you to install it.

这种很糟糕,我是关注点分离的忠实粉丝,并且保留一个只存在的模块列表以便它们可以被其他模块吸收是糟糕的.

This kind of stinks, I'm a big fan of the separation of concerns, and keeping a list of modules that only exist so they can be absorbed by other modules is crummy.

但是,它就是这样,只要你利用提供给你的 npm 命令,我想它是可以管理的.

But, it is what it is and so long as you leverage the npm commands afforded to you, I guess it's manageable.

这篇关于使用命令在 npm 中保存对等依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆