pnpm

What is the equivalent to npm install --legacy-peer-deps for pnpm?


What is the equivalent of npm install --legacy-peer-deps for pnpm?

I tried pnpm install --legacy-peer-deps but it is not recognized:

 ERROR   ERROR  Unknown option: 'legacy-peer-deps'
Did you mean 'strict-peer-dependencies'? Use "--config.unknown=value" to force an unknown option.

Should I just use pnpm config set auto-install-peers true and then pnpm install?


Solution

  • In pnpm, there isn’t a direct --legacy-peer-deps option like in npm. However, you can achieve a similar effect by setting strict-peer-dependencies to false, which makes pnpm less strict about peer dependency conflicts.

    Here are a couple of ways to do this:

    Option 1: Use strict-peer-dependencies=false at Install

    You can run:

    pnpm install --strict-peer-dependencies=false
    

    This will tell pnpm to ignore peer dependency conflicts for that installation.

    Option 2: Configure in .npmrc for Persistent Behavior

    To make this setting persistent for your project, add the following line to your project’s .npmrc file:

    strict-peer-dependencies=false
    

    This will apply the relaxed peer dependency setting to all pnpm installations for this project, similar to --legacy-peer-deps in npm.