Search code examples
reactjspackage.jsonnpm-publish

Installing private react package gives error due to peer dependencies


I am trying to create and publish a private library of reusable UI components. From what I could find on the web, it is best practice to include react and react-dom as peerDependencies to allow the user installing the package to decide whether which version of react to choose (this makes sense).

But whenever I do try to install it, I get an error:

Could not resolve dependency: peer react@"^16.8.6" from @xyz/xyz@1.0.1

More so it says that react version found is react@undefined. Which makes sense because it is added in peerDependency.

Any advice on how to approach this?


Solution

  • Solved the issue,

    I had wrongly configured the configuration .npmrc file. Fixed it by correcting the scope registry.