Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lts/* in .nvmrc files #137

Closed
joshburgess opened this issue Aug 31, 2019 · 8 comments · Fixed by #146
Closed

Support lts/* in .nvmrc files #137

joshburgess opened this issue Aug 31, 2019 · 8 comments · Fixed by #146

Comments

@joshburgess
Copy link

joshburgess commented Aug 31, 2019

Currently, lts/* is considered an acceptable version by nvm. It knows to treat this as the latest LTS version. However, fnm doesn't seem to understand this syntax even though it's a valid .nvmrc config. Would it be possible to support this?

@Schniz
Copy link
Owner

Schniz commented Sep 1, 2019

Let's say you have Node 8 installed, should fnm use lts/* use it, or in return say "you don't have Node 10 installed"?

The former is possible, by traversing on every lts-* alias and choose the latest version between them. But I think that's not what you'd expect for as a user. The latter is also possible but probably require a network call on use, which is not ideal and will make things potentially slow.

I think that neither are good options because there are breaking changes between LTS versions (I have seen projects that bumping Node versions to 10 was problematic.) and therefore its okay to only support the lts/SPECIFIC_VERSION syntax. If we decide that we don't support it (until we find a performant and easy-to-grasp way to handle it), we should throw an error when seeing lts/*, and saying that we don't support - and maybe link to this very issue.

What do you think?

@joshburgess
Copy link
Author

I think explicitly stating in the documentation that fnm does not support lts/* due to the authors/maintainers believing it is not a safe/good practice + throwing an error when a user attempts to use fnm with an .nvmrc containing lts/*, informing the user that this isn't supported, is probably okay.

I just made this issue because the docs stated that fnm was fully compatible with .nvmrc, but then I found this edge case where it's not.

@joshburgess
Copy link
Author

joshburgess commented Sep 2, 2019

However, if you do want to support it, I believe the 2nd of the two options you listed, in return say "you don't have Node 10 installed", would be closer to how nvm works, as lts/* is supposed to just use the most recent lts version available.

I am not familiar with the internals of fnm, but wouldn't the slowness only be introduced in the specific case of where lts/* is detected in the config file? I imagine the process would be something like:

-> `lts/*` is not detected
   -> `fnm` continues to work as it does now
-> `lts/*` is detected
  -> first, make a network request to discover the latest node LTS available
  -> then, check the user's installed versions of node
     -> if installed, use this version
     -> if not installed, prompt the user with a message like:
        "The current LTS is v_._._, which you do not have installed. Install v_._._? Y/N"

@Schniz
Copy link
Owner

Schniz commented Sep 12, 2019

As @dcodeIO has mentioned on Twitter (or maybe I inferred it from that thread), a good case for lts/* is nightly builds on CI. Even then, I probably wouldn't use it — I'd rather have a specific lts version mentioned, instead of be surprised when the version bumped.

I am not familiar with the internals of fnm, but wouldn't the slowness only be introduced in the specific case of where lts/* is detected in the config file? — @joshburgess

It can be! The only thing left to understand now is how to make the most performant latest lts checks.
I just found https://nodejs.org/dist/index.json and we can filter by lts: true and then sort by semver 😄 This file can be cached in the future.

use can work by looking for lts-* aliases, sorting by semver and using it

@ljharb
Copy link

ljharb commented Sep 12, 2019

I use lts/* on all my linting builds, as well as npx aud audit runs. It doesn’t matter what version of node they run with as long as it’s late enough, and it’s more reliable than using latest.

@nikitavoloboev
Copy link

How can you setup to use lts version? I tried fnm install lts and it doesn't work.

@Schniz
Copy link
Owner

Schniz commented Sep 24, 2019

Right now, use a specific lts version, like fnm install lts/dubnium. I need to work on making fnm install lts/* work. Then, we could practically support fnm install lts that would be the same, or fnm install --lts (that I believe nvm does?)

@ljharb
Copy link

ljharb commented Sep 24, 2019

nvm supports both; double dash for the command line, the slash form is for config files.

This was referenced Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants