DEV Community

Aashutosh Poudel
Aashutosh Poudel

Posted on

5 2

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.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more