During this standard, we will go through how to handle versions dependencies of different packages to a same package.
If some package doesn't use same versions of a package, depending of the order it will be called, it won't be the same version of package used. We want to ensure that the same version is used everywhere in the app.
Normally this would require to manually edit
yarn.lockfile, but it is really bad because this file is deleted each time you install a new package or run a yarn command.
By chance, yarn has a feature override, which allows us to fix those versions dependencies.
- Have a react native app installed
- Identify the case:
- you just installed a new package (I just installed
react-native-datepicker) and there is a regression in the app (in my case
moment.locale()was not working anymore)
- you're trying to set a parameter of a package (e.g. the default locale of
moment) but it's not taken into account by another package
- Then open
- look for your newly installed package* look for this package dependencies:
- try to find other packages which depends on another version of
- search for
- if another package depends on it but in another version, several lines for
- find which other package it is by searching for
momentin dependencies section of packages:
moment ">= 2.9.0"
package.jsonfile, add a section 'resolutions' at the same level as the 'dependencies' section.
- Specify to which version of
momentdepend the two packages, choose same version number for both:
- If the package is a dependency of your app, you'll need to set its version in the
Check your yarn.lock file,
momentshould appears in only one line:
which means that every package depending on
momentis resolved to a same version (here 2.19.1).
Your app should works correctly now, regression should be solved.
momentdependencies are solved.