javascript - what's the difference of optionalDependencies and peerDependenciesMeta's optional? - Stack Overflow

both of them are marking dependency as optional, so what's the use-case of each?Is peerDependenci

both of them are marking dependency as optional, so what's the use-case of each?

Is peerDependenciesMeta for npm package and the optionalDependencies for project?

I have a npm package, some modules in it need dependency foo, but if you don't import it, the relative peerDependency is able to not install

both of them are marking dependency as optional, so what's the use-case of each?

Is peerDependenciesMeta for npm package and the optionalDependencies for project?

I have a npm package, some modules in it need dependency foo, but if you don't import it, the relative peerDependency is able to not install

Share Improve this question asked Dec 26, 2022 at 2:22 homyhomy 4014 silver badges13 bronze badges 1
  • 1 Take a look here classic.yarnpkg./lang/en/docs/dependency-types – vicki Commented Dec 26, 2022 at 9:12
Add a ment  | 

1 Answer 1

Reset to default 5

TL;DR

peerDependenciesMeta allows specifying peerDependencies as optional optionalDependencies allows specifying regular dependencies as optional


Entries in optionalDependencies have the same semantics as entries in dependencies. I.e., transitive optionalDependencies may end up in nested node_modules, and installed packages can have their own copies of their optionalDependencies available to them, at conflicting versions with each other.

peerDependencies are always shared (singletons) and installed in the top-level node_modules. They must not be installed in nested node_modules if they conflict. peerDependenciesMeta allows you to specify some peerDependencies as optional.

See the npm docs for optionalDependencies and peerDependencies for more info.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745498056a4630282.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信