mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-04 03:33:46 +00:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
31e58d1827 | ||
![]() |
a32b914bab | ||
![]() |
f51b1bf8ae | ||
![]() |
c874a17479 | ||
![]() |
6eef4ce4d2 | ||
![]() |
54476476ab | ||
![]() |
87a3a4425d | ||
![]() |
17a3272b8a | ||
![]() |
c08010f610 | ||
![]() |
2ee8ec886f | ||
![]() |
978f7b4435 | ||
![]() |
3417e9d9a3 | ||
![]() |
eb4de62bc1 | ||
![]() |
8a199e00a2 | ||
![]() |
6ac7ecf7dc | ||
![]() |
a09f225ec7 | ||
![]() |
e0e1c0379a | ||
![]() |
f4d57cc17d |
@@ -9,7 +9,7 @@ Note: `nvm` does not support Windows (see [#284](https://github.com/creationix/n
|
||||
- [nodist](https://github.com/marcelklehr/nodist)
|
||||
|
||||
Note: `nvm` does not support [Fish] either (see [#303](https://github.com/creationix/nvm/issues/303)). Alternatives exist, which are neither supported nor developed by us:
|
||||
- [bass](https://github.com/edc/bass) allows to use utilities written for Bash in fish shell
|
||||
- [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell
|
||||
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
|
||||
- [fin](https://github.com/fisherman/fin) is a pure fish node version manager for fish shell
|
||||
- [plugin-nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell
|
||||
@@ -30,24 +30,29 @@ Note: On OS X, if you have/had a "system" node installed and want to install mod
|
||||
|
||||
Homebrew installation is not supported. If you have issues with homebrew-installed `nvm`, please `brew uninstall` it, and install it using the instructions below, before filing an issue.
|
||||
|
||||
Note: If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm_update` to update.
|
||||
Note: If you're using `zsh` you can easily install `nvm` as a zsh plugin. Install [`zsh-nvm`](https://github.com/lukechilds/zsh-nvm) and run `nvm upgrade` to upgrade.
|
||||
|
||||
### Install script
|
||||
|
||||
To install or update nvm, you can use the [install script][2] using cURL:
|
||||
|
||||
```sh
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
|
||||
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
|
||||
```
|
||||
|
||||
or Wget:
|
||||
|
||||
```sh
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | bash
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
|
||||
```
|
||||
|
||||
<sub>The script clones the nvm repository to `~/.nvm` and adds the source line to your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`).</sub>
|
||||
|
||||
```sh
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
```
|
||||
|
||||
You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables.
|
||||
Eg: `curl ... | NVM_DIR=/usr/local/nvm bash` for a global install.
|
||||
|
||||
@@ -76,16 +81,18 @@ which should output 'nvm' if the installation was successful. Please note that `
|
||||
|
||||
For manual install create a folder somewhere in your filesystem with the `nvm.sh` file inside it. I put mine in `~/.nvm`.
|
||||
|
||||
Or if you have `git` installed, then just clone it, and check out the latest version:
|
||||
Or if you have `git` installed (requires git v1.5.5+):
|
||||
|
||||
1. clone this repo
|
||||
1. check out the latest version
|
||||
1. activate nvm by sourcing it from your shell
|
||||
|
||||
```sh
|
||||
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`
|
||||
```
|
||||
|
||||
To activate nvm, you need to source it from your shell:
|
||||
|
||||
```sh
|
||||
. ~/.nvm/nvm.sh
|
||||
export NVM_DIR="$HOME/.nvm" && (
|
||||
git clone https://github.com/creationix/nvm.git "$NVM_DIR"
|
||||
cd "$NVM_DIR"
|
||||
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
|
||||
) && . "$NVM_DIR/nvm.sh"
|
||||
```
|
||||
|
||||
Add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:
|
||||
@@ -98,16 +105,19 @@ export NVM_DIR="$HOME/.nvm"
|
||||
|
||||
### Manual upgrade
|
||||
|
||||
For manual upgrade with `git`, change to the `$NVM_DIR`, pull down the latest changes, and check out the latest version:
|
||||
For manual upgrade with `git` (requires git v1.5.5+):
|
||||
|
||||
1. change to the `$NVM_DIR`
|
||||
1. pull down the latest changes
|
||||
1. check out the latest version
|
||||
1. activate the new version
|
||||
|
||||
```sh
|
||||
cd "$NVM_DIR" && git fetch origin && git checkout `git describe --abbrev=0 --tags`
|
||||
```
|
||||
|
||||
After upgrading, don't forget to activate the new version:
|
||||
|
||||
```sh
|
||||
. "$NVM_DIR/nvm.sh"
|
||||
(
|
||||
cd "$NVM_DIR"
|
||||
git fetch origin
|
||||
git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
|
||||
) && . "$NVM_DIR/nvm.sh"
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -394,7 +404,7 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh
|
||||
|
||||
```sh
|
||||
apk add bash
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.3/install.sh | /bin/bash
|
||||
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | /bin/bash
|
||||
```
|
||||
|
||||
The Node project has some desire but no concrete plans (due to the overheads of building, testing and support) to offer Alpine-compatible binaries.
|
||||
@@ -425,7 +435,7 @@ After the v0.8.6 release of node, nvm tries to install from binary packages. But
|
||||
If setting the `default` alias does not establish the node version in new shells (i.e. `nvm current` yields `system`), ensure that the system's node PATH is set before the `nvm.sh` source line in your shell profile (see [#658](https://github.com/creationix/nvm/issues/658))
|
||||
|
||||
[1]: https://github.com/creationix/nvm.git
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.31.3/install.sh
|
||||
[2]: https://github.com/creationix/nvm/blob/v0.31.4/install.sh
|
||||
[3]: https://travis-ci.org/creationix/nvm
|
||||
[Urchin]: https://github.com/scraperwiki/urchin
|
||||
[Fish]: http://fishshell.com
|
||||
|
12
install.sh
12
install.sh
@@ -11,7 +11,7 @@ nvm_install_dir() {
|
||||
}
|
||||
|
||||
nvm_latest_version() {
|
||||
echo "v0.31.3"
|
||||
echo "v0.31.4"
|
||||
}
|
||||
|
||||
#
|
||||
@@ -40,7 +40,7 @@ nvm_source() {
|
||||
echo "$NVM_SOURCE_URL"
|
||||
}
|
||||
|
||||
#
|
||||
#
|
||||
# Node.js version to install
|
||||
#
|
||||
nvm_node_version() {
|
||||
@@ -103,7 +103,6 @@ nvm_install_node() {
|
||||
NODE_VERSION="$(nvm_node_version)"
|
||||
|
||||
if [ -z "$NODE_VERSION" ]; then
|
||||
echo "=> You can now install Node.js by running \`nvm install\`"
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -290,14 +289,17 @@ nvm_do_install() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Sourcing $PROFILE to take into account the new environment
|
||||
. "$NVM_PROFILE"
|
||||
# Source nvm
|
||||
. "$NVM_DIR/nvm.sh"
|
||||
|
||||
nvm_check_global_modules
|
||||
|
||||
nvm_install_node
|
||||
|
||||
nvm_reset
|
||||
|
||||
echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
|
||||
printf "$SOURCE_STR"
|
||||
}
|
||||
|
||||
#
|
||||
|
6
nvm.sh
6
nvm.sh
@@ -814,7 +814,7 @@ nvm_ls() {
|
||||
SEARCH_PATTERN="$(echo "${PATTERN}" | sed "s#\.#\\\.#g;")"
|
||||
fi
|
||||
if [ -n "$NVM_DIRS_TO_SEARCH1$NVM_DIRS_TO_SEARCH2$NVM_DIRS_TO_SEARCH3" ]; then
|
||||
VERSIONS="$(command find "$NVM_DIRS_TO_SEARCH1"/* "$NVM_DIRS_TO_SEARCH2"/* "$NVM_DIRS_TO_SEARCH3"/* -name . -o -type d -prune -o -name "$PATTERN*" \
|
||||
VERSIONS="$(command find "$NVM_DIRS_TO_SEARCH1"/* "$NVM_DIRS_TO_SEARCH2"/* "$NVM_DIRS_TO_SEARCH3"/* -name . -o -type d -prune -o -path "$PATTERN*" \
|
||||
| command sed "
|
||||
s#${NVM_VERSION_DIR_IOJS}/#versions/${NVM_IOJS_PREFIX}/#;
|
||||
s#^${NVM_DIR}/##;
|
||||
@@ -1235,6 +1235,8 @@ nvm_get_arch() {
|
||||
EXIT_CODE=$?
|
||||
if [ $EXIT_CODE -ne 0 ]; then
|
||||
HOST_ARCH=$(isainfo -n)
|
||||
else
|
||||
HOST_ARCH=$(echo "$HOST_ARCH" | tail -1)
|
||||
fi
|
||||
else
|
||||
HOST_ARCH="$(command uname -m)"
|
||||
@@ -2764,7 +2766,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | nvm_grep -v "N/A" | command sed '/^$/d')"
|
||||
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
|
||||
;;
|
||||
"--version" )
|
||||
nvm_echo '0.31.3'
|
||||
nvm_echo '0.31.4'
|
||||
;;
|
||||
"unload" )
|
||||
unset -f nvm nvm_print_versions nvm_checksum \
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nvm",
|
||||
"version": "0.31.3",
|
||||
"version": "0.31.4",
|
||||
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
|
@@ -32,6 +32,8 @@ setup_mock_arch() {
|
||||
ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo
|
||||
if [ "_$OPT" != "_no_pkg_info" ]; then
|
||||
ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info
|
||||
else
|
||||
ln -sf "${MOCKS_DIR}/pkg_info_fail" ./pkg_info
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -1 +1,4 @@
|
||||
# On SmartOS 64bits setups, pkg_info outputs _both_ i386 and x86_64
|
||||
# architectures as architectures supported by pkg_install.
|
||||
echo "i386"
|
||||
echo "x86_64"
|
||||
|
1
test/mocks/pkg_info_fail
Executable file
1
test/mocks/pkg_info_fail
Executable file
@@ -0,0 +1 @@
|
||||
exit 1
|
Reference in New Issue
Block a user