Search code examples
npmnpm-install

How can I make npm install package and ignore one (or all) peer dependencies?


I have [email protected] installed. I want to install vuex-module-decorators@latest, which has a peerDependency of vuex 3 (not >=3). I have a feeling this will work fine with vuex 4. Is there a way for me to tell npm to install this new package, without crashing due to not being able to resolve the peer dependency (since 4 != 3)? Or do I need to just create my own fork of vuex-module-decorators with an updated package.json that allows vuex >=3?


Solution

  • Fast but potentially unsafe: Using --legacy-peer-deps will usually allow you to install the package without meeting the peer dependency requirements. (This was the default using npm@6 so I assume you are using npm@7 or later if you are seeing a problem.) If that doesn't work, --force will install without regard to peer dependencies.

    Requires slightly more effort but is more safe/surgical: Use npm overrides. These were introduced in npm 8.x.