When it comes to expressing dependencies for your library, there are a couple of ways to do so (technically three, but let's focus on the main two for now).
peerDependencies
- This type of dependency is ideal when:
- Your library specifically requires a certain version of another library.
- Your library may encounter conflicts if multiple versions of the same dependency exist in the
node_modules
folder due to transitive dependencies.
- You want developers using your library to have control over which version of the dependency they choose.
It's worth noting that peerDependencies
won't be automatically installed; instead, it will notify users of your library about any missing or incompatible dependencies.
2.dependencies
- If you're not concerned about the scenarios mentioned above, simply list your dependencies here. Including something like vtk.js
as a dependency ensures it will be automatically installed for anyone using your library.