S
S
sutaaliya2020-11-24 18:33:36
JavaScript
sutaaliya, 2020-11-24 18:33:36

How does peerDependencies work in package.json?

Can you please explain on your fingers how and why to use peerDependencies on the project? What to write there? I'm trying to understand, but googling it didn't add clarity to me. Do I understand correctly that it is necessary to write there those dependencies that can be intertwined in different commands, so that when building with webpack, it does not duplicate them in the bundle? How does it even work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wondermarin, 2020-11-24
@sutaaliya

Not really sure where you found this, but Google can find the answer in less than 10 seconds.

peerDependencies are a special type of dependency that can only occur if you publish your own package.
Having peerDependencies means that your package needs the same dependency as the person installing your package. Used for packages like react that need to have a single copy of react-dom that is also used by the person installing it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question