fnm icon indicating copy to clipboard operation
fnm copied to clipboard

Feature: Add a command like nvm install node

Open lukecotter opened this issue 3 years ago • 5 comments

First of all, just wanted to say thanks, the speed difference between this and nvm is insane 😄

Feature request Could we get a command similar to nvm install node to install the latest version of node? nvm default node, nvm use node are also really useful to stay up to date with the latest.

I have scripts that automatically update the default node version for use with some global packages that have to be global.

lukecotter avatar Mar 10 '21 12:03 lukecotter

Greetings, do you want to install latest, or latest LTS version? (the latter is what I generally recommend)

Schniz avatar Mar 10 '21 15:03 Schniz

Yes it the latest I am after.

I normally like to get the latest node to test against and check for compatibility of some apps etc as soon as new versions are available.

I have a script I run periodically to update node and other things. It just makes it simpler to always get latest than to run the list command manually every now and then, or use grep of course 😉

lukecotter avatar Mar 11 '21 21:03 lukecotter

I'd also recommend LTS for production, however, in development most of us tend to use the latest stable version instead, in order to find and fix breaking changes early.

alumni avatar May 26 '21 10:05 alumni

Something like this should work (tested on MacOS):

V=$(fnm ls-remote | sort -V | tail -n 1 | tr -d '\n') && fnm install $V && fnm default $V

egorovli avatar Nov 18 '21 18:11 egorovli

Something like this should work (tested on MacOS):

V=$(fnm ls-remote | sort -V | tail -n 1 | tr -d '\n') && fnm install $V && fnm default $V

Thanks, I ended up with something similar.

This gives the latest major version number, then I let the install command handle installing latest minor via sem version.

fnm ls-remote | cut -d "." -f1 | cut -d "v" -f2 | tail -1

I also grab any global packages so they can be reinstalled after upgrade of node.

npm ls -g | cut -d "@" -f1 | cut -d " " -f2 | tail -n +2 | tr "\n" " " | awk '{$1=$1};1'

I am sure both those could be improved, but they work 🤷🏻‍♂️

lukecotter avatar Dec 14 '21 15:12 lukecotter