mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-12-12 16:14:18 +00:00
Compare commits
2 Commits
58b3d9be3f
...
travis3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f32e7bad4 | ||
|
|
9bd27d3897 |
@@ -100,8 +100,6 @@ nvm is a version manager for [node.js](https://nodejs.org/en/), designed to be i
|
|||||||
|
|
||||||
### Install & Update Script
|
### Install & Update Script
|
||||||
|
|
||||||
**If you use macOS, you must install Xcode and agree to the Xcode License before you install nvm.**
|
|
||||||
|
|
||||||
To **install** or **update** nvm, you should run the [install script][2]. To do that, you may either download and run the script manually, or use the following cURL or Wget command:
|
To **install** or **update** nvm, you should run the [install script][2]. To do that, you may either download and run the script manually, or use the following cURL or Wget command:
|
||||||
```sh
|
```sh
|
||||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||||
@@ -110,7 +108,7 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
|||||||
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to `~/.nvm`, and attempts to add the source lines from the snippet below to the correct profile file (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`). **If you don't have a profile file in your home dir, you'll need to add the appropriate one before you run the script.**
|
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to `~/.nvm`, and attempts to add the source lines from the snippet below to the correct profile file (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).
|
||||||
|
|
||||||
<a id="profile_snippet"></a>
|
<a id="profile_snippet"></a>
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
15
nvm.sh
15
nvm.sh
@@ -196,9 +196,6 @@ nvm_install_latest_npm() {
|
|||||||
nvm_echo 'Attempting to upgrade to the latest working version of npm...'
|
nvm_echo 'Attempting to upgrade to the latest working version of npm...'
|
||||||
local NODE_VERSION
|
local NODE_VERSION
|
||||||
NODE_VERSION="$(nvm_strip_iojs_prefix "$(nvm_ls_current)")"
|
NODE_VERSION="$(nvm_strip_iojs_prefix "$(nvm_ls_current)")"
|
||||||
local NPM_VERSION
|
|
||||||
NPM_VERSION="$(npm --version 2>/dev/null)"
|
|
||||||
|
|
||||||
if [ "${NODE_VERSION}" = 'system' ]; then
|
if [ "${NODE_VERSION}" = 'system' ]; then
|
||||||
NODE_VERSION="$(node --version)"
|
NODE_VERSION="$(node --version)"
|
||||||
elif [ "${NODE_VERSION}" = 'none' ]; then
|
elif [ "${NODE_VERSION}" = 'none' ]; then
|
||||||
@@ -209,6 +206,8 @@ nvm_install_latest_npm() {
|
|||||||
nvm_err 'Unable to obtain node version.'
|
nvm_err 'Unable to obtain node version.'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
local NPM_VERSION
|
||||||
|
NPM_VERSION="$(npm --version 2>/dev/null)"
|
||||||
if [ -z "${NPM_VERSION}" ]; then
|
if [ -z "${NPM_VERSION}" ]; then
|
||||||
nvm_err 'Unable to obtain npm version.'
|
nvm_err 'Unable to obtain npm version.'
|
||||||
return 2
|
return 2
|
||||||
@@ -701,12 +700,10 @@ nvm_ensure_version_installed() {
|
|||||||
nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."
|
nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."
|
||||||
fi
|
fi
|
||||||
nvm_err ""
|
nvm_err ""
|
||||||
if [ "${PROVIDED_VERSION}" = 'lts' ]; then
|
if [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; 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.'
|
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
|
||||||
elif [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
|
else
|
||||||
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
|
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
|
||||||
else
|
|
||||||
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
|
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
Reference in New Issue
Block a user