Have you encountered when you are working on a project and you want to upgrade a dependency but you can’t do because you will have to migrate a lot of code or you should test your project with multi-versions of some module(s)?
Personally, I make and maintain a lot of Koa modules. Sometimes, I need to make the modules work with all versions of Koa so this is a real example how i do to solve this problem.
Alias allows you to install multiple versions of a same package in the same project.
You can use the alias by following this command:
npm i <your-alias>@npm:<package-name>
yarn add <your-alias>@npm:<package-name>
When you want to install a specific version of the package append the command with
For example, we want to use Koa with release
1.x.x and the latest one
npm i koa-v1@npm:koa@1 npm i koa@npm:koa
yarn add koa-v1@npm:koa@1 yarn add koa@npm:koa
Now, when you import the Koa module using
koa-v1, it means that you are using
email@example.com. Otherwise, when importing with
koa, it means that you are using the latest version of