{{ message }}
[patch] give a more helpful message when lts alias is mistakenly used - #3441
Merged
Conversation
Member
ljharb
marked this pull request as draft
October 5, 2024 04:11
Contributor
Author
|
I understand that If we cannot modify the |
Member
|
Yes, in general the error message can be improved; please do update this PR to do so instead. |
Contributor
Author
r4reetik
marked this pull request as ready for review
October 5, 2024 04:49
nvm use lts Command to Correctly Map to Latest LTS Versionnvm use lts command to show better error message.
ljharb
requested changes
Oct 5, 2024
ljharb
left a comment
Member
There was a problem hiding this comment.
This is fine, but we'll need a test for it.
ljharb
approved these changes
Oct 5, 2024
ljharb
force-pushed
the
chore/use-lts
branch
2 times, most recently
from
October 6, 2024 01:49
9877db5 to
5dc31ac
Compare
nvm use lts command to show better error message.lts alias is mistakenly used
This comment was marked as spam.
This comment was marked as spam.
ljharb
added a commit
that referenced
this pull request
Mar 11, 2025
New Stuff - `install.sh`: add `$ZDOTDIR` to zsh search (#3458) Fixes - `reinstall-packages`: do not reinstall corepack (#3544) - avoid bash-specific syntax (#3499) - `install-latest-npm`: npm v11 is out - `nvm_install_latest_npm`: avoid unbound variable (#3447) - give a more helpful message when `lts` alias is mistakenly used (#3441) - `nvm ls`, `nvm alias`, `nvm install`: error when an LTS name is invalid - `nvm_normalize_lts`: error when an LTS name is not lowercase (#3417) Documentation - [readme] update link - [readme] fix `--no-use` example (#3479) - [readme] update copyright notice (#3507) - [readme] note zsh-nvm's AUTO_USE option (#2670) - [readme] add note about reloading zshrc after editing (#3052) - [readme] Update shell profile file install notes (#2241) - [readme] add docker tips (#2318) - [readme] remove `avn` from readme (#3469) - [readme] fnm -> nvm.fish (#2541) Refactors - prefer `case` over if/else chains - combine `sed -e` invocations/arguments Tests - `nvm exec`/`nvm run`: add `--silent` tests (#1259) - [actions] release test needs git tags - migrate `installation_iojs` test suite to GitHub Actions (#3476) - Migrate slow test suite from Travis CI (#3470) - temporarily skip this failing travis test to unblock progress - [actions] TOC: use latest LTS node - `install.sh`: clean up `nvm_detect_profile` tests - `nvm_detect_profile`: refactor (#3467) - run urchin tests on pull requests (#3466) - update mocks - ensure that unit tests use only mocked LTS names - [actions] use `node/install` instead of `node/run` Meta - disable blank issues - update issue template - add DCO (#3456) - Rename .github/ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md (#3454)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Issue
When using the command
nvm use lts, users encounter the following error message:However, the LTS version is already installed on the system, and the command nvm use --lts works correctly. This inconsistency causes confusion and inconvenience for users who expect nvm use lts to function as intended.
Solution
The issue was identified in the
nvm_remote_versionfunction within thenvm.shscript. The function did not correctly handle theltsalias, leading to the error message.To resolve this, I modified the
nvm_remote_versionfunction to include a case for theltsalias. The updated function now correctly maps theltsalias to the latest LTS version.nvm.sh: Added a case for "lts" to thenvm_remote_version()function to retrieve the latest LTS version usingnvm_ls_remote.Impact
This change ensures that the command
nvm use ltscorrectly maps to the latest LTS version, providing a consistent and expected user experience. Users will no longer encounter the error message when the LTS version is already installed on their system.