Compare commits

...

3 Commits

Author SHA1 Message Date
Calin
6af0a66bd6
Merge 9a445a9d87132554e3caee9b0a5107bc5a1d4a25 into 5dc31ac51b08f910a2de1596b37a6a3dddd5e7b7 2024-10-07 20:13:00 +05:30
Reetik Rajan
5dc31ac51b
[patch] give a more helpful message when lts alias is mistakenly used 2024-10-05 09:21:42 +05:30
Calin
9a445a9d87
Update README.md
Added another item to troubleshooting macOS
2021-04-20 11:06:07 +02:00
3 changed files with 27 additions and 4 deletions

View File

@ -156,6 +156,8 @@ If you get `nvm: command not found` after running the install script, one of the
- You might need to restart your terminal instance or run `. ~/.nvm/nvm.sh`. Restarting your terminal/opening a new tab/window, or running the source command will load the command and the new configuration.
- The file `~/.nvm/nvm.sh` might not have execution rights. Try running `chmod a+x ~/.nvm/nvm.sh`
- If the above didn't help, you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
If the above doesn't fix the problem, you may try the following:

10
nvm.sh
View File

@ -700,10 +700,12 @@ nvm_ensure_version_installed() {
nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."
fi
nvm_err ""
if [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
else
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
if [ "${PROVIDED_VERSION}" = 'lts' ]; then
nvm_err '`lts` is not an alias - you may need to run `nvm install --lts` to install and `nvm use --lts` to use it.'
elif [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
else
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
fi
return 1
fi

View File

@ -0,0 +1,19 @@
#!/bin/sh
set -ex
die () { echo "$@" ; exit 1; }
\. ../../../nvm.sh
# Deactivate any active node version
nvm deactivate >/dev/null 2>&1 || die 'deactivate failed'
# Attempt to use 'lts' without '--' and capture the error message
ERROR_OUTPUT=$(nvm use lts 2>&1) || true
EXPECTED_ERROR='`lts` is not an alias - you may need to run `nvm install --lts` to install and `nvm use --lts` to use it.'
# Check if the error message matches the expected output
echo "$ERROR_OUTPUT" | grep -q "$EXPECTED_ERROR" \
|| die "Expected error message not found. Got: $ERROR_OUTPUT"