[Fix] nvm install: keep nvm options after the version out of ./configure

Options after the version went to `./configure` for a source install and were ignored for a binary install.

`--latest-npm`, `--default`, `--alias`, `--save` and `--no-progress` now also work after the version,
like `--reinstall-packages-from` already does.
`-s`, `-b`, `-j`, `--offline` and `--lts` are checked,
or used to find the version, before it is resolved:
after the version they now fail right away with a message to put them first,
and so do `---` typos.

Fixes #2066.
This commit is contained in:
Yashvardhan Thanvi authored and Jordan Harband committed 2026-11-04 00:37:28 +05:30
1 parent d190476345
commit 6131a266a4
2 files changed
+143

No files matched your search

+36
View File
@@ -5083,6 +5083,15 @@ nvm() {
NVM_ONLY_FLAG="${NVM_INSTALL_ARG#--only=}"
NVM_ONLY_FLAG_COUNT=$((NVM_ONLY_FLAG_COUNT + 1))
;;
---*)
nvm_err 'arguments with `---` are not supported - this is likely a typo'
return 55;
;;
# these are checked, or used to find the version, before it is resolved
-s | -b | -j | --offline | --lts | --lts=*)
nvm_err "\`${NVM_INSTALL_ARG}\` must appear directly after \`nvm install\`, before the version"
return 6
;;
esac
done
@@ -5274,6 +5283,33 @@ nvm() {
--skip-default-packages)
SKIP_DEFAULT_PACKAGES=true
;;
--no-progress)
noprogress=1
;;
--latest-npm)
NVM_UPGRADE_NPM=1
;;
--default)
if [ -n "${ALIAS-}" ]; then
nvm_err '--default and --alias are mutually exclusive, and may not be provided more than once'
return 6
fi
ALIAS='default'
;;
--alias=*)
if [ -n "${ALIAS-}" ]; then
nvm_err '--default and --alias are mutually exclusive, and may not be provided more than once'
return 6
fi
ALIAS="${1##--alias=}"
;;
--save | -w)
if [ $NVM_WRITE_TO_NVMRC -eq 1 ]; then
nvm_err '--save and -w may only be provided once'
return 6
fi
NVM_WRITE_TO_NVMRC=1
;;
--only=*) ;;
*)
ADDITIONAL_PARAMETERS="${ADDITIONAL_PARAMETERS} $1"