Search code examples
npmpackage.jsonpnpmpeer-dependencies

What should I do with peer dependencies of dependencies when I develop a library?


Here the situation : I work on a library that has dependencies which themselves have peer-dependencies.

When doing a pnpm install, of course I have an error because of unresolved peer-dependencies.

Also, the library does not use these peer-dependencies.

What should I do ? use .npmrc to auto-install them ? forward them as peer-dependency ? another thing ?

(Note : the library was initially using npm)


Solution

  • I guess just use auto-install-peers=true in your .npmrc. This setting will be true by default from pnpm v8.

    Alternatively, you may install the missing peer dependencies as dev dependencies of you package.

    There is no need to add them to peer dependencies unless you use them in code.