Override version for package dependency

1 min read

Selective dependency resolutions

Today I learned how to resolve dependency version with yarn.

Imagine you have react-native-permissions in your package.json.

At the same time, you also have let's say react-native-qrcode-scanner with dependencies on react-native-permissions.

Now, an issue arose when both the react-native-permissions require different versions, with one of them introduces breaking changes.

This is the kind of scenario where we can use selective dependency resolutions.

Usage example, in package.json:

"resolutions": { "react-native-permissions": "^3.8.4" }

This will then override the version of react-native-permissions in react-native-qrcode-scanner therefore resolve the issue.

Thanks for reading. Always keep learning!