Compare commits

...

4 Commits

Author SHA1 Message Date
tim-mit
f8617341f5
Merge 5f7d419458 into 99352a64d2 2025-04-15 23:02:28 -07:00
Toni Viemerö
99352a64d2
[Fix] nvm_install_latest_npm: fix node version detection 2025-04-09 08:16:05 +03:00
tim-mit
5f7d419458
Merge branch 'master' into issue3034 2023-08-27 19:10:32 +12:00
Tim Toomey
b42c165667 [Fix] gracefully handle GNU tar on MacOS during nvm install
GNU tar doesn't support using the -J flag required to unpack
xz-compressed tarballs when xv isn't installed. Check for this
scenario and fallback to using gzip-compressed tarballs.

Fixes #3034
2023-08-27 18:49:27 +12:00

20
nvm.sh
View File

@ -356,19 +356,19 @@ nvm_install_latest_npm() {
if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then
NVM_IS_20_5_OR_ABOVE=1 NVM_IS_20_5_OR_ABOVE=1
fi fi
local NVM_IS_20_17_or_ABOVE local NVM_IS_20_17_OR_ABOVE
NVM_IS_20_17_or_ABOVE=0 NVM_IS_20_17_OR_ABOVE=0
if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater 20.17.0 "${NODE_VERSION}"; then if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.17.0; then
NVM_IS_20_17_or_ABOVE=1 NVM_IS_20_17_OR_ABOVE=1
fi fi
local NVM_IS_21_OR_ABOVE local NVM_IS_21_OR_ABOVE
NVM_IS_21_OR_ABOVE=0 NVM_IS_21_OR_ABOVE=0
if [ $NVM_IS_20_17_or_ABOVE -eq 1 ] && nvm_version_greater 21.0.0 "${NODE_VERSION}"; then if [ $NVM_IS_20_17_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 21.0.0; then
NVM_IS_21_OR_ABOVE=1 NVM_IS_21_OR_ABOVE=1
fi fi
local NVM_IS_22_9_OR_ABOVE local NVM_IS_22_9_OR_ABOVE
NVM_IS_22_9_OR_ABOVE=0 NVM_IS_22_9_OR_ABOVE=0
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater 22.9.0 "${NODE_VERSION}"; then if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 22.9.0; then
NVM_IS_22_9_OR_ABOVE=1 NVM_IS_22_9_OR_ABOVE=1
fi fi
@ -420,7 +420,7 @@ nvm_install_latest_npm() {
nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`' nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`'
$NVM_NPM_CMD install -g npm@9 $NVM_NPM_CMD install -g npm@9
elif \ elif \
[ $NVM_IS_20_17_or_ABOVE -eq 0 ] \ [ $NVM_IS_20_17_OR_ABOVE -eq 0 ] \
|| { [ $NVM_IS_21_OR_ABOVE -eq 1 ] && [ $NVM_IS_22_9_OR_ABOVE -eq 0 ]; } \ || { [ $NVM_IS_21_OR_ABOVE -eq 1 ] && [ $NVM_IS_22_9_OR_ABOVE -eq 0 ]; } \
; then ; then
nvm_echo '* `npm` `v10.x` is the last version that works on `node` `< v20.17`, `v21`, or `v22.0` - `v22.8`' nvm_echo '* `npm` `v10.x` is the last version that works on `node` `< v20.17`, `v21`, or `v22.0` - `v22.8`'
@ -4556,7 +4556,11 @@ nvm_supports_xz() {
if [ "_${NVM_OS}" = '_darwin' ]; then if [ "_${NVM_OS}" = '_darwin' ]; then
local MACOS_VERSION local MACOS_VERSION
MACOS_VERSION="$(sw_vers -productVersion)" MACOS_VERSION="$(sw_vers -productVersion)"
if nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then if tar --version | command grep -q GNU && ! command which xz >/dev/null 2>&1; then
# On macOS with GNU tar in use, and no xv on the path, xv-compressed
# tarballs aren't supported
return 1
elif nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
# macOS 10.8 and earlier doesn't support extracting xz-compressed tarballs with tar # macOS 10.8 and earlier doesn't support extracting xz-compressed tarballs with tar
return 1 return 1
fi fi