Search code examples
javascriptnpmdependencies

Make your NPM package support multiple versions of peer dependency


I have a package on NPM that is using React version 15 as peer dependency. However, I want it to stop from throwing warnings for users that upgraded their React version. How do I make package support both version 15 and 16?

"peerDependencies": {
    "react-dom": "^15.0.0"
  },

which is the most convenient way to deal with these?

Is "*15.0.0" good enough?


Solution

  • To address a range you can use following notation :

    "peerDependencies": {
        "react-dom": "15 - 16"
    }
    

    Makes it really easy to define a range as well.

    You can test them out here : https://semver.npmjs.com/