Search code examples
pnpmpeer-dependencies

What is the best practice to resolving this peer dependencies issue?


I've node.js and pnpm installed, with

pnpm config set auto-install-peers true

If I type :

pnpx create-next-app //(named my-app)
cd my-app
pnpm add @rainbow-me/rainbowkit

enter image description here

What is the right way to fix this ? If best practice needs to remove my auto-install-peers setting I'm ok with this.

my package.json for information, after typing theses commands :

{
  "name": "mwe",
  "version": "0.1.0",
  "private": true,
  "scripts": {
(...)
  },
  "dependencies": {
    "@rainbow-me/rainbowkit": "^0.7.3",
    "next": "12.3.1",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },
  "devDependencies": {
    "eslint": "8.26.0",
    "eslint-config-next": "12.3.1"
  }
}


Solution

  • This is not related to the auto-install-peers setting.

    You have react v18.2.0 in your dependencies but react-native wants react 18.1.0. To fix this, you can downgrade react to v18.1.0. Alternatively, if you are sure that react-native works fine with the installed version of react, you may mute this warning by using the pnpm.peerDependencyRules.allowedVersions field in package.json. For instance:

    {
      "pnpm": {
        "peerDependencyRules": {
          "allowedVersions": {
            "react": "18"
          }
        }
      }
    }