jorgebucaran / nvm.fish

The Node.js version manager you'll adore, crafted just for Fish
https://git.io/nvm.fish
MIT License
2.06k stars 69 forks source link

nvm install-latest-npm equivalent #202

Open KerickHowlett opened 1 year ago

KerickHowlett commented 1 year ago

Is there a way to mirror the native nvm feature of installing the latest npm version for the current Node version?

Recently, I ran into an issue where I had to use Node v12 for a project and executed npm i -g npm, which installed a version of npm that's incompatible with Node v12.

Native nvm has the means to install the latest npm version intelligently for specific Node versions by executing nvm install-latest-npm.

Is there a way to mirror that feature for nvm.fish?

ljharb commented 1 year ago

As far as I'm aware, nvm is the only thing in the ecosystem that encapsulates this logic. (linking to https://github.com/nvm-sh/nvm/issues/3010)

KerickHowlett commented 1 year ago

Hello again! lol

Is there a way to put a nvm.fish wrapper around that particular command?

jorgebucaran commented 1 year ago

Sorry for the late reply. Could you please help me understand what install-latest-npm is and how it could be useful? I haven't come across a situation where I needed it, so I'm not sure how or why I should port it to nvm.fish.

KerickHowlett commented 1 year ago

TL;DR: Was working on an Angular project that hadn't been updated in a real long time, and I believe I ran into an edge case where updating npm made it to where I couldn't install or run anything, because it wouldn't work with Node 12.

Full Explanation

At the time I posted this issue at work where I attempted to install the latest version of npm after having to switch to (what I believe was) Node 12.

Anytime I install a different Node version, I'll install the latest version of npm immediately out of habit.

This resulted in many issues where I couldn't get anything to run or install for the project. After some investigating and debugging, I ended up having to uninstall everything for Node 12, only without updating npm to get it to work.

Now, a part of my frustrating journey here led me to asking the team behind the original nvm -- I know you don't actually reuse any of their code, but I was looking for answers where I could find them -- and they told me I had installed an incompatible version of npm that wasn't fully compatible with Node 12.

That was when they instructed me to use npm-install-latest, because it used logic to install the latest version of npm still compatible with an argued version of Node.

With all that said, I will also add I discovered something, after making my initial post, where the project I had been working on was using a dependency which had had deprecated for a long time -- or may have even reached its EOL -- that had been causing problems with the project installations. The library was old enough to require the legacy flag, anyway.

While I believe the issue I posted is still valid, the outdated dependency may have also contributed to the roadblock I was facing at the time.