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
- 1 Take a look here classic.yarnpkg./lang/en/docs/dependency-types – vicki Commented Dec 26, 2022 at 9:12
1 Answer
Reset to default 5TL;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条)