1

Pardon my ignorance, if I am developing a library, should (some of) my peerDependencies be duplicated in my devDependencies? I'm thinking yes, right?

Example:


  "peerDependencies": {
    "@babel/runtime": "7.6.0", <- needed for consuming the transpiled library
    "sugar-date": "2.0.6",
    "yup": "0.27.0"
  },  
  "devDependencies": {
    "sugar-date": "2.0.6", <- this is actually a "dependency"
    "yup": "0.27.0", <- this is actually a "dependency"
    ...
   }

Because this is a library, if I put them as dependencies, then in the project that consumes them, they will install their own node_modules when the project might already contain these dependencies, resulting in duplicated code - so I put them in peerDependencies to avoid this. But now I can't develop (e.g. write tests), so I have to put them in devDependencies.

Is this correct? Am I misunderstanding something?

tk421
  • 5,775
  • 6
  • 23
  • 34
Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100
  • Googlefu has shown me that this is still a point of contention: https://github.com/yarnpkg/yarn/issues/1503 – Adam Jenkins Sep 26 '19 at 14:45
  • This doesn't solve the question asked, but `npm install` usually avoids duplicate dependency installation (https://docs.npmjs.com/cli/install#algorithm), so you might be okay using regular dependencies. – Half Oct 01 '19 at 16:41

0 Answers0