nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
80.77k stars 8.04k forks source link

NVM doesn't know the installed lts version is outdated. #3198

Open avin-kavish opened 1 year ago

avin-kavish commented 1 year ago
$ nvm use --lts
Now using node v16.17.0 (npm v8.15.0)

$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v18.18.0...
Downloading https://nodejs.org/dist/v18.18.0/node-v18.18.0-linux-x64.tar.xz...
############################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v18.18.0 (npm v9.8.1)

I typed nvm use while node 16 was installed as the lts version. It used 16 without actually checking whether it was the current LTS version. Would be good if it did the check.

ljharb commented 1 year ago

It's actually a very good thing it doesn't, because nvm use shouldn't ever make a network call.

I agree that trying to install --lts when the local machine resolves that to 16.17, and getting "not that", is a bug. However, the local machine not updating its local LTS mapping until a network call is made is quite intentional.

ljharb commented 1 year ago

hmm, thinking about this more. if you wanted to stay on the LTS line, you'd have done nvm install --lts=gallium. by asking for --lts, you're explicitly asking for the latest possible LTS thing.

I could certainly add some warning output when the version you may have expected to get has, due to server updates, changed - would that help?

avin-kavish commented 1 year ago

yeah, I think.

Also this might be a bit more advanced, don't know if it's possible - it could check the LTS expiry date from a local lookup table. I think these dates are set in advance so it could cache a table from the last network call.

ljharb commented 1 year ago

I’m intentionally not going to make anything time-based in nvm; those dates change, and system clocks aren’t always correct, and EOL status doesn’t change what version of node you need.

avin-kavish commented 1 year ago

Right, I think in that case just a notice would work - using "latest locally installed lts version" or similar...

unlikelyzero commented 8 months ago

For my usecase, I'd like to be able to ensure that my build is always installing the latest version from the lts/iron line. Should I run nvm clear cache before doing a nvm install lts/iron?

ljharb commented 8 months ago

@unlikelyzero no need; the install command will always get the latest version. The cache doesn’t prevent version listing, it only stores binaries and source.