Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
17.52k stars 444 forks source link

Enable the `use` command to specify 'latest' or 'lts' #935

Open jenewland1999 opened 1 year ago

jenewland1999 commented 1 year ago

Would be neat if you could specify lts or latest for the use command either as an option (e.g. --lts and --latest) or as the version arg (e.g. lts and latest)

Example using options

fnm use --lts
fnm use --latest

Example using args

fnm use lts
fnm use latest

Considerations

What happens if you don't have the version installed?

What happens when they're already using it

GMkonan commented 1 year ago

Are there any issues or PR's related to this? Scanning through the docs and other issues, I didn't find anything. I want to be able to put this on my automated installation process in my dotfiles. For that, I would like to install the lts version (which I know it's already possible) and use it automatically. That would be enough for me to change from nvm to fnm.

jenewland1999 commented 1 year ago

Are there any issues or PR's related to this? Scanning through the docs and other issues, I didn't find anything. I want to be able to put this on my automated installation process in my dotfiles. For that, I would like to install the lts version (which I know it's already possible) and use it automatically. That would be enough for me to change from nvm to fnm.

I did look through the issues prior to submitting this one and I didn't see anything that resembled this feature. If you wanted to automate the installation it does appear that if you simply install fnm and then do fnm install --lts or fnm install --latest provided you have a single version it will be set as the default.

Granted that's not really a great solution but it's a temporary work around. I'm sure there's other ways around it too using bash magic, though that's way beyond me 😅.

polarathene commented 10 months ago

Would be neat if you could specify lts or latest for the use command either as an option (e.g. --lts and --latest) or as the version arg (e.g. lts and latest)

Aliases would provide this functionality?:

--lts and --latest options however differ and can resolve to whatever is relevant at the time queried. Using the options makes more sense due to that. UPDATE: fnm install --lts will update the lts-latest alias when appropriate, while a PR is open contributing the same feature for --latest.

In my initial experience with fnm (due to a bug mentioned below), I was also trying to figure out how to fnm use (or similar commands) with a node version installed with --lts or --latest. If the options were supported, that'd work just as well.


If you wanted to automate the installation it does appear that if you simply install fnm and then do fnm install --lts or fnm install --latest provided you have a single version it will be set as the default.

Presently there is a bug where this advice does not apply if you used fnm install with --corepack-enabled.

robw-mercury commented 5 months ago

nvm uses node in the nvmrc file as an alias for latest. It would be nice to have interoperability.

sdavids commented 3 weeks ago

What will be the meaning of --lts considering there are 2 (soon 3) currently:

https://nodejs.org/en/about/previous-releases

--lts means active LTS?

jenewland1999 commented 3 weeks ago

What will be the meaning of --lts considering there are 2 (soon 3) currently:

  • 18 - Hydrogen
  • 20 - Iron
  • (22 - whatever name is chosen for it)

https://nodejs.org/en/about/previous-releases

--lts means active LTS?

Good point, something I hadn't considered, though yeah I'd likely expect it to use the active LTS (the one that downloads by default on nodejs.org)

bgmort commented 2 weeks ago

This could be considered a separate issue, or a part of this issue, but I'd like to request also supporting the value node in .nvmrc for compatibility with nvm: https://github.com/nvm-sh/nvm?tab=readme-ov-file#nvmrc

jenewland1999 commented 2 weeks ago

This could be considered a separate issue, or a part of this issue, but I'd like to request also supporting the value node in .nvmrc for compatibility with nvm: https://github.com/nvm-sh/nvm?tab=readme-ov-file#nvmrc

Can't speak for the fnm project, but imho this would be a separate issue, if anything because it focuses on greater compatability with nvm and likely would involve changes different to that of what this issue is asking for. Great suggestion though! 🙂