DEV Community

Aashutosh Poudel
Aashutosh Poudel

Posted on

Install multiple versions of same package using yarn

I had an issue in react native with libraries: react-native-picker-select and @react-native-picker/picker. react-native-picker-select uses @react-native-picker/picker internally, and the version is far behind the current version. So I tried installing the latest version of @react-native-picker/picker separately but got an error saying: RNCAndroidDialogPicker was declared twice or something similar.

Anyways, I couldn't solve the issue but found aliases in npm/yarn.

With aliases you could add node packages with a different name and import them without any issues.

yarn add your-custom-name@npm:@react-native-picker/picker
Enter fullscreen mode Exit fullscreen mode

This way I can define a new name for the latest version of the @react-native-picker/picker library and import it in my components with the new name. The same name will be added to the package.json file.

Top comments (0)