The inevitable quarandate.

I wore a black spaghetti top and pajama shorts(obviously.) Fortunately I didn’t have to shave anything for this date. What a relief. Guess there is a upside to all of this after all. I texted him 15…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to Install Multiple Versions of the Same Package in NPM

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?

But for some reason, we can’t just update it directly because our current version and the latest version contains some breaking changes. Yes, there is a migration step illustrated but we can’t just migrate all the places where it is being used due to time constraints and priorities.

And the fact that it takes a lot of hard work to make sure everything is working as expected. We don’t want to break existing parts just because we missed some migration steps.

Is it possible to install the latest version in isolation so it will not affect other parts of our code?

Yes oh yes. But before that, let’s make sure we are on the correct version of Node.js and NPM. Let’s get started with that!

To sum it up:

NPM version: 6.9.0 or above ✅

Node version: 10.16.0 or above ✅

Now that we already have the correct version, let’s see our command to execute.

The NPM command we are going to use is called package aliases and here is the command:

Let’s replace those placeholders with our real values

This will install the latest version available on NPM.

The usage of that would be something like:

Then if you want to use the latest one, just use the alias name in the import

Installing with alias is a great way to do especially if you have a legacy project which is one of the best use cases for it since you can upgrade the packages gradually.

You don’t have to worry about regressions or breaking other parts of the system easily.

You can try the latest version of your favorite library in isolation on your new task that you are working on without worries.

But on the other side, we shouldn’t do a lot of package aliases instead we should be responsible for migrating other parts little by little because it will pile up. And when it comes to the point you have a lot of package aliases, it might slow down the performance of installing your project (this can result in longer hours in the pipeline) and a bigger bundle of the application.

Did I miss something? Let me know in the comment section and let’s work on that.

Thank you for reading. I hope this will help you on your journey! ❤️

Add a comment

Related posts:

The Best Cat Food For Indoor Cats

We all want to give our cats the best nutrition possible as cat owners, but it can be challenging to decide which cat food to buy with so many options available. IAMS PROACTIVE HEALTH Adult Indoor…

Dijkstra Algorithm

Here is the pseudocode for Dijkstra’s algorithm, as described as follows: DIJKSTRA(G, w, s) Step1. for each vertex v in G Step2. d[v] <- infinity Step3. pred[v] <- null Step4. d[s] <- 0 Step5. Q <…

Poems From the Other Side

I have commented recently on a story about writing from the heart and not for the wallet, which is pretty much how I live my life in full. Sadly, for my wallet and shoe collection. I don’t feel…