Compare commits

...

10 Commits

Author SHA1 Message Date
Huy Z 294ff9e3aa
[readme] Fix uninstall instructions
`nvm unload` will unset NVM_DIR. So gotta save NVM_DIR first.
2024-02-13 03:39:07 -08:00
Raphael Boidol c24c3134a7
[actions] update action versions to use node 20 2024-02-18 21:56:53 +01:00
Jordi Paris Ferrer c82e7a6f62
Fix typo in WSL section of README
`u` -> `you`
2024-02-17 16:39:36 -08:00
jbidad 4e2a71ba9b
[Docs] add `nvm unload` to uninstall nvm instructions 2024-01-18 12:07:01 +03:30
Jordan Harband 6c9cd2f2d1
[security] fix typo in threat model 2023-12-15 09:46:35 -08:00
Jordan Harband bab86d5de5
v0.39.7 2023-12-05 21:50:27 -08:00
Jordan Harband d86f270438
[Fix] use `\hash` instead of `command hash` for `zsh`
See #3239; Fixes #3247; Closes #3246
2023-12-05 21:48:51 -08:00
Jordan Harband c73009f503
v0.39.6 2023-12-04 22:03:25 -08:00
Ben Wiley 7aee54b76c
[readme] reorganize “deeper shell integration” instructions 2017-06-29 14:23:03 -04:00
Chris Meyers 6262b5a666
[readme] rearrange install args 2023-10-23 21:48:11 -06:00
13 changed files with 87 additions and 80 deletions

View File

@ -11,7 +11,7 @@ The aim of this section is to facilitate the identification of potential securit
The following assets are considered important for the `nvm` project: The following assets are considered important for the `nvm` project:
- `nvm` source code and project documentation - `nvm` source code and project documentation
- Underlying `nvm`` dependencies - Underlying `nvm` dependencies
- `nvm` development infrastructure - `nvm` development infrastructure
- `nvm` installed devices including servers - `nvm` installed devices including servers

View File

@ -9,11 +9,12 @@ jobs:
latest: ${{ steps.set-matrix.outputs.requireds }} latest: ${{ steps.set-matrix.outputs.requireds }}
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
iojs.org:443 iojs.org:443
nodejs.org:443 nodejs.org:443
raw.githubusercontent.com:443
- uses: ljharb/actions/node/matrix@main - uses: ljharb/actions/node/matrix@main
id: set-matrix id: set-matrix
with: with:
@ -46,7 +47,7 @@ jobs:
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
@ -54,7 +55,7 @@ jobs:
iojs.org:443 iojs.org:443
nodejs.org:443 nodejs.org:443
registry.npmjs.org:443 registry.npmjs.org:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main - uses: ljharb/actions/node/install@main
name: 'install node' name: 'install node'
with: with:
@ -75,7 +76,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
egress-policy: block egress-policy: block
- run: 'echo tests completed' - run: 'echo tests completed'

View File

@ -8,14 +8,14 @@ jobs:
contents: read contents: read
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: step-security/harden-runner@v1 - uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
raw.githubusercontent.com:443 raw.githubusercontent.com:443
nodejs.org:443 nodejs.org:443
registry.npmjs.org:443 registry.npmjs.org:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main - uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install' name: 'nvm install ${{ matrix.node-version }} && npm install'
with: with:
@ -27,7 +27,7 @@ jobs:
contents: read contents: read
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: step-security/harden-runner@v1 - uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
ghcr.io:443 ghcr.io:443
@ -36,7 +36,7 @@ jobs:
pkg-containers.githubusercontent.com:443 pkg-containers.githubusercontent.com:443
nodejs.org:443 nodejs.org:443
registry.npmjs.org:443 registry.npmjs.org:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main - uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install' name: 'nvm install ${{ matrix.node-version }} && npm install'
with: with:
@ -48,14 +48,14 @@ jobs:
contents: read contents: read
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: step-security/harden-runner@v1 - uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
raw.githubusercontent.com:443 raw.githubusercontent.com:443
nodejs.org:443 nodejs.org:443
registry.npmjs.org:443 registry.npmjs.org:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main - uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install' name: 'nvm install ${{ matrix.node-version }} && npm install'
with: with:
@ -67,11 +67,11 @@ jobs:
contents: read contents: read
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: step-security/harden-runner@v1 - uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
raw.githubusercontent.com:443 raw.githubusercontent.com:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: check tests filenames - name: check tests filenames
run: ./rename_test.sh --check run: ./rename_test.sh --check

View File

@ -12,12 +12,12 @@ jobs:
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
api.github.com:443 api.github.com:443
github.com:443 github.com:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: ljharb/rebase@master - uses: ljharb/rebase@master
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -9,13 +9,16 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
api.github.com:443
objects.githubusercontent.com:443
raw.githubusercontent.com:443
registry.npmjs.org:443 registry.npmjs.org:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: "14" node-version: "14"
- run: npm install - run: npm install

View File

@ -12,7 +12,7 @@ jobs:
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
api.github.com:443 api.github.com:443

View File

@ -27,13 +27,14 @@ jobs:
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
ghcr.io:443 ghcr.io:443
github.com:443 github.com:443
pkg-containers.githubusercontent.com:443 pkg-containers.githubusercontent.com:443
- uses: actions/checkout@v3 formulae.brew.sh:443
- uses: actions/checkout@v4
- name: Set up Homebrew - name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master uses: Homebrew/actions/setup-homebrew@master
- name: Install latest shellcheck - name: Install latest shellcheck
@ -52,7 +53,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
egress-policy: block egress-policy: block
- run: 'echo tests completed' - run: 'echo tests completed'

View File

@ -26,7 +26,7 @@ jobs:
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
@ -34,7 +34,7 @@ jobs:
raw.githubusercontent.com:443 raw.githubusercontent.com:443
nodejs.org:443 nodejs.org:443
iojs.org:443 iojs.org:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }} - run: sudo ${{ matrix.shell }} --version 2> /dev/null || dpkg -s ${{ matrix.shell }} 2> /dev/null || which ${{ matrix.shell }}
- run: curl --version - run: curl --version
- run: wget --version - run: wget --version

View File

@ -12,12 +12,12 @@ jobs:
steps: steps:
- name: Harden Runner - name: Harden Runner
uses: step-security/harden-runner@v1 uses: step-security/harden-runner@v2
with: with:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
registry.npmjs.org:443 registry.npmjs.org:443
- uses: actions/checkout@v3 - uses: actions/checkout@v4
with: with:
# https://github.com/actions/checkout/issues/217#issue-599945005 # https://github.com/actions/checkout/issues/217#issue-599945005
# pulls all commits (needed for lerna / semantic release to correctly version) # pulls all commits (needed for lerna / semantic release to correctly version)
@ -25,7 +25,7 @@ jobs:
# pulls all tags (needed for lerna / semantic release to correctly version) # pulls all tags (needed for lerna / semantic release to correctly version)
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: '16' node-version: '16'
- run: npm install - run: npm install

View File

@ -6,7 +6,7 @@
</a> </a>
# Node Version Manager [![Build Status](https://app.travis-ci.com/nvm-sh/nvm.svg?branch=master)][3] [![nvm version](https://img.shields.io/badge/version-v0.39.5-yellow.svg)][4] [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/684/badge)](https://bestpractices.coreinfrastructure.org/projects/684) # Node Version Manager [![Build Status](https://app.travis-ci.com/nvm-sh/nvm.svg?branch=master)][3] [![nvm version](https://img.shields.io/badge/version-v0.39.7-yellow.svg)][4] [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/684/badge)](https://bestpractices.coreinfrastructure.org/projects/684)
<!-- To update this table of contents, ensure you have run `npm install` then `npm run doctoc` --> <!-- To update this table of contents, ensure you have run `npm install` then `npm run doctoc` -->
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- START doctoc generated TOC please keep comment here to allow auto update -->
@ -41,12 +41,10 @@
- [Use a mirror of node binaries](#use-a-mirror-of-node-binaries) - [Use a mirror of node binaries](#use-a-mirror-of-node-binaries)
- [.nvmrc](#nvmrc) - [.nvmrc](#nvmrc)
- [Deeper Shell Integration](#deeper-shell-integration) - [Deeper Shell Integration](#deeper-shell-integration)
- [bash](#bash) - [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file)
- [Automatically call `nvm use`](#automatically-call-nvm-use) - [bash](#bash)
- [zsh](#zsh) - [zsh](#zsh)
- [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file) - [fish](#fish)
- [fish](#fish)
- [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file-1)
- [Running Tests](#running-tests) - [Running Tests](#running-tests)
- [Environment variables](#environment-variables) - [Environment variables](#environment-variables)
- [Bash Completion](#bash-completion) - [Bash Completion](#bash-completion)
@ -101,10 +99,10 @@ nvm is a version manager for [node.js](https://nodejs.org/en/), designed to be i
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.39.5/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
``` ```
```sh ```sh
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/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`). 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`).
@ -126,7 +124,7 @@ Eg: `curl ... | NVM_DIR="path/to/nvm"`. Ensure that the `NVM_DIR` does not conta
- The installer can use `git`, `curl`, or `wget` to download `nvm`, whichever is available. - The installer can use `git`, `curl`, or `wget` to download `nvm`, whichever is available.
- You can instruct the installer to not edit your shell config (for example if you already get completions via a [zsh nvm plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/nvm)) by setting `PROFILE=/dev/null` before running the `install.sh` script. Here's an example one-line command to do that: `PROFILE=/dev/null bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash'` - You can instruct the installer to not edit your shell config (for example if you already get completions via a [zsh nvm plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/nvm)) by setting `PROFILE=/dev/null` before running the `install.sh` script. Here's an example one-line command to do that: `PROFILE=/dev/null bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash'`
#### Troubleshooting on Linux #### Troubleshooting on Linux
@ -174,7 +172,7 @@ You can use a task:
```yaml ```yaml
- name: Install nvm - name: Install nvm
ansible.builtin.shell: > ansible.builtin.shell: >
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
args: args:
creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh" creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh"
``` ```
@ -236,7 +234,7 @@ If you have `git` installed (requires git v1.7.10+):
1. clone this repo in the root of your user profile 1. clone this repo in the root of your user profile
- `cd ~/` from anywhere then `git clone https://github.com/nvm-sh/nvm.git .nvm` - `cd ~/` from anywhere then `git clone https://github.com/nvm-sh/nvm.git .nvm`
1. `cd ~/.nvm` and check out the latest version with `git checkout v0.39.5` 1. `cd ~/.nvm` and check out the latest version with `git checkout v0.39.7`
1. activate `nvm` by sourcing it from your shell: `. ./nvm.sh` 1. activate `nvm` by sourcing it from your shell: `. ./nvm.sh`
Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login: Now add these lines to your `~/.bashrc`, `~/.profile`, or `~/.zshrc` file to have it automatically sourced upon login:
@ -356,7 +354,7 @@ Any time your local copy of `nvm` connects to https://nodejs.org, it will re-cre
To get the latest LTS version of node and migrate your existing installed packages, use To get the latest LTS version of node and migrate your existing installed packages, use
```sh ```sh
nvm install 'lts/*' --reinstall-packages-from=current nvm install --reinstall-packages-from=current 'lts/*'
``` ```
### Migrating Global Packages While Installing ### Migrating Global Packages While Installing
@ -364,7 +362,7 @@ nvm install 'lts/*' --reinstall-packages-from=current
If you want to install a new version of Node.js and migrate npm packages from a previous version: If you want to install a new version of Node.js and migrate npm packages from a previous version:
```sh ```sh
nvm install node --reinstall-packages-from=node nvm install --reinstall-packages-from=node node
``` ```
This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one. This will first use "nvm version node" to identify the current version you're migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs "nvm reinstall-packages" to reinstall the npm packages from your prior version of Node to the new one.
@ -372,8 +370,8 @@ This will first use "nvm version node" to identify the current version you're mi
You can also install and migrate npm packages from specific versions of Node like this: You can also install and migrate npm packages from specific versions of Node like this:
```sh ```sh
nvm install 6 --reinstall-packages-from=5 nvm install --reinstall-packages-from=5 6
nvm install v4.2 --reinstall-packages-from=iojs nvm install --reinstall-packages-from=iojs v4.2
``` ```
Note that reinstalling packages _explicitly does not update the npm version_ — this is to ensure that npm isn't accidentally upgraded to a broken version for the new node version. Note that reinstalling packages _explicitly does not update the npm version_ — this is to ensure that npm isn't accidentally upgraded to a broken version for the new node version.
@ -381,7 +379,7 @@ Note that reinstalling packages _explicitly does not update the npm version_ —
To update npm at the same time add the `--latest-npm` flag, like this: To update npm at the same time add the `--latest-npm` flag, like this:
```sh ```sh
nvm install 'lts/*' --reinstall-packages-from=default --latest-npm nvm install --reinstall-packages-from=default --latest-npm 'lts/*'
``` ```
or, you can at any time run the following command to get the latest supported npm version on the current node version: or, you can at any time run the following command to get the latest supported npm version on the current node version:
@ -415,7 +413,7 @@ nvm install iojs
If you want to install a new version of io.js and migrate npm packages from a previous version: If you want to install a new version of io.js and migrate npm packages from a previous version:
```sh ```sh
nvm install iojs --reinstall-packages-from=iojs nvm install --reinstall-packages-from=iojs iojs
``` ```
The same guidelines mentioned for migrating npm packages in node are applicable to io.js. The same guidelines mentioned for migrating npm packages in node are applicable to io.js.
@ -575,52 +573,53 @@ You can also use [`nvshim`](https://github.com/iamogbz/nvshim) to shim the `node
If you prefer a lighter-weight solution, the recipes below have been contributed by `nvm` users. They are **not** supported by the `nvm` maintainers. We are, however, accepting pull requests for more examples. If you prefer a lighter-weight solution, the recipes below have been contributed by `nvm` users. They are **not** supported by the `nvm` maintainers. We are, however, accepting pull requests for more examples.
#### bash #### Calling `nvm use` automatically in a directory with a `.nvmrc` file
##### Automatically call `nvm use` In your profile (`~/.bash_profile`, `~/.zshrc`, `~/.profile`, or `~/.bashrc`), add the following to `nvm use` whenever you enter a new directory:
##### bash
Put the following at the end of your `$HOME/.bashrc`: Put the following at the end of your `$HOME/.bashrc`:
```bash ```bash
cdnvm() { cdnvm() {
command cd "$@" || return $? command cd "$@" || return $?
nvm_path=$(nvm_find_up .nvmrc | tr -d '\n') nvm_path="$(nvm_find_up .nvmrc | command tr -d '\n')"
# If there are no .nvmrc file, use the default nvm version # If there are no .nvmrc file, use the default nvm version
if [[ ! $nvm_path = *[^[:space:]]* ]]; then if [[ ! $nvm_path = *[^[:space:]]* ]]; then
declare default_version; declare default_version
default_version=$(nvm version default); default_version="$(nvm version default)"
# If there is no default version, set it to `node` # If there is no default version, set it to `node`
# This will use the latest version on your machine # This will use the latest version on your machine
if [[ $default_version == "N/A" ]]; then if [ $default_version = 'N/A' ]; then
nvm alias default node; nvm alias default node
default_version=$(nvm version default); default_version=$(nvm version default)
fi fi
# If the current version is not the default version, set it to use the default version # If the current version is not the default version, set it to use the default version
if [[ $(nvm current) != "$default_version" ]]; then if [ "$(nvm current)" != "${default_version}" ]; then
nvm use default; nvm use default
fi fi
elif [[ -s "${nvm_path}/.nvmrc" && -r "${nvm_path}/.nvmrc" ]]; then
elif [[ -s $nvm_path/.nvmrc && -r $nvm_path/.nvmrc ]]; then
declare nvm_version declare nvm_version
nvm_version=$(<"$nvm_path"/.nvmrc) nvm_version=$(<"${nvm_path}"/.nvmrc)
declare locally_resolved_nvm_version declare locally_resolved_nvm_version
# `nvm ls` will check all locally-available versions # `nvm ls` will check all locally-available versions
# If there are multiple matching versions, take the latest one # If there are multiple matching versions, take the latest one
# Remove the `->` and `*` characters and spaces # Remove the `->` and `*` characters and spaces
# `locally_resolved_nvm_version` will be `N/A` if no local versions are found # `locally_resolved_nvm_version` will be `N/A` if no local versions are found
locally_resolved_nvm_version=$(nvm ls --no-colors "$nvm_version" | tail -1 | tr -d '\->*' | tr -d '[:space:]') locally_resolved_nvm_version=$(nvm ls --no-colors "${nvm_version}" | command tail -1 | command tr -d '\->*' | command tr -d '[:space:]')
# If it is not already installed, install it # If it is not already installed, install it
# `nvm install` will implicitly use the newly-installed version # `nvm install` will implicitly use the newly-installed version
if [[ "$locally_resolved_nvm_version" == "N/A" ]]; then if [ "${locally_resolved_nvm_version}" = 'N/A' ]; then
nvm install "$nvm_version"; nvm install "${nvm_version}";
elif [[ $(nvm current) != "$locally_resolved_nvm_version" ]]; then elif [ "$(nvm current)" != "${locally_resolved_nvm_version}" ]; then
nvm use "$nvm_version"; nvm use "${nvm_version}";
fi fi
fi fi
} }
@ -631,9 +630,9 @@ cdnvm "$PWD" || exit
This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version. This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.
#### zsh ##### zsh
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file This shell function will install (if needed) and `nvm use` the specified Node version when an `.nvmrc` is found, and `nvm use default` otherwise.
Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you enter a directory that contains an Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you enter a directory that contains an
`.nvmrc` file with a string telling nvm which node to `use`: `.nvmrc` file with a string telling nvm which node to `use`:
@ -665,9 +664,8 @@ add-zsh-hook chpwd load-nvmrc
load-nvmrc load-nvmrc
``` ```
#### fish ##### fish
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file
This requires that you have [bass](https://github.com/edc/bass) installed. This requires that you have [bass](https://github.com/edc/bass) installed.
```fish ```fish
# ~/.config/fish/functions/nvm.fish # ~/.config/fish/functions/nvm.fish
@ -824,13 +822,13 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh
### Alpine Linux 3.13+ ### Alpine Linux 3.13+
```sh ```sh
apk add -U curl bash ca-certificates openssl ncurses coreutils python3 make gcc g++ libgcc linux-headers grep util-linux binutils findutils apk add -U curl bash ca-certificates openssl ncurses coreutils python3 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
``` ```
### Alpine Linux 3.5 - 3.12 ### Alpine Linux 3.5 - 3.12
```sh ```sh
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
``` ```
_Note: Alpine 3.5 can only install NodeJS versions up to v6.9.5, Alpine 3.6 can only install versions up to v6.10.3, Alpine 3.7 installs versions up to v8.9.3, Alpine 3.8 installs versions up to v8.14.0, Alpine 3.9 installs versions up to v10.19.0, Alpine 3.10 installs versions up to v10.24.1, Alpine 3.11 installs versions up to v12.22.6, Alpine 3.12 installs versions up to v12.22.12, Alpine 3.13 & 3.14 install versions up to v14.20.0, Alpine 3.15 & 3.16 install versions up to v16.16.0 (**These are all versions on the main branch**). Alpine 3.5 - 3.12 required the package `python2` to build NodeJS, as they are older versions to build. Alpine 3.13+ requires `python3` to successfully build newer NodeJS versions, but you can use `python2` with Alpine 3.13+ if you need to build versions of node supported in Alpine 3.5 - 3.15, you just need to specify what version of NodeJS you need to install in the package install script._ _Note: Alpine 3.5 can only install NodeJS versions up to v6.9.5, Alpine 3.6 can only install versions up to v6.10.3, Alpine 3.7 installs versions up to v8.9.3, Alpine 3.8 installs versions up to v8.14.0, Alpine 3.9 installs versions up to v10.19.0, Alpine 3.10 installs versions up to v10.24.1, Alpine 3.11 installs versions up to v12.22.6, Alpine 3.12 installs versions up to v12.22.12, Alpine 3.13 & 3.14 install versions up to v14.20.0, Alpine 3.15 & 3.16 install versions up to v16.16.0 (**These are all versions on the main branch**). Alpine 3.5 - 3.12 required the package `python2` to build NodeJS, as they are older versions to build. Alpine 3.13+ requires `python3` to successfully build newer NodeJS versions, but you can use `python2` with Alpine 3.13+ if you need to build versions of node supported in Alpine 3.5 - 3.15, you just need to specify what version of NodeJS you need to install in the package install script._
@ -846,8 +844,12 @@ As a potential alternative, @mhart (a Node contributor) has some [Docker images
To remove `nvm` manually, execute the following: To remove `nvm` manually, execute the following:
First, use `nvm unload` to remove the nvm command from your terminal session and delete the installation directory:
```sh ```sh
$ rm -rf "$NVM_DIR" $ nvm_dir="${NVM_DIR:-~/.nvm}"
$ nvm unload
$ rm -rf "$nvm_dir"
``` ```
Edit `~/.bashrc` (or other shell resource config) and remove the lines below: Edit `~/.bashrc` (or other shell resource config) and remove the lines below:
@ -929,9 +931,9 @@ You have to make sure that the user directory name in `$HOME` and the user direc
To change the user directory and/or account name follow the instructions [here](https://support.apple.com/en-us/HT201548) To change the user directory and/or account name follow the instructions [here](https://support.apple.com/en-us/HT201548)
[1]: https://github.com/nvm-sh/nvm.git [1]: https://github.com/nvm-sh/nvm.git
[2]: https://github.com/nvm-sh/nvm/blob/v0.39.5/install.sh [2]: https://github.com/nvm-sh/nvm/blob/v0.39.7/install.sh
[3]: https://app.travis-ci.com/nvm-sh/nvm [3]: https://app.travis-ci.com/nvm-sh/nvm
[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.39.5 [4]: https://github.com/nvm-sh/nvm/releases/tag/v0.39.7
[Urchin]: https://git.sdf.org/tlevine/urchin [Urchin]: https://git.sdf.org/tlevine/urchin
[Fish]: https://fishshell.com [Fish]: https://fishshell.com
@ -989,7 +991,7 @@ Here's what you will need to do:
If one of these broken versions is installed on your system, the above step will likely still succeed even if you didn't include the `--shared-zlib` flag. If one of these broken versions is installed on your system, the above step will likely still succeed even if you didn't include the `--shared-zlib` flag.
However, later, when you attempt to `npm install` something using your old version of node.js, you will see `incorrect data check` errors. However, later, when you attempt to `npm install` something using your old version of node.js, you will see `incorrect data check` errors.
If you want to avoid the possible hassle of dealing with this, include that flag. If you want to avoid the possible hassle of dealing with this, include that flag.
For more details, see [this issue](https://github.com/nodejs/node/issues/39313) and [this comment](https://github.com/nodejs/node/issues/39313#issuecomment-902395576) For more details, see [this issue](https://github.com/nodejs/node/issues/39313) and [this comment](https://github.com/nodejs/node/issues/39313#issuecomment-90.39.776)
- Exit back to your native shell. - Exit back to your native shell.
@ -1016,7 +1018,7 @@ Now you should be able to use node as usual.
If you've encountered this error on WSL-2: If you've encountered this error on WSL-2:
```sh ```sh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:09 --:--:-- 0curl: (6) Could not resolve host: raw.githubusercontent.com 0 0 0 0 0 0 0 0 --:--:-- 0:00:09 --:--:-- 0curl: (6) Could not resolve host: raw.githubusercontent.com
@ -1037,7 +1039,7 @@ This could simply be solved by running this in your root directory:
sudo chattr +i /etc/resolv.conf sudo chattr +i /etc/resolv.conf
``` ```
This deletes your `resolv.conf` file that is automatically generated when u run WSL, creates a new file and puts `nameserver 8.8.8.8`, then creates a `wsl.conf` file and adds `[network]` and `generateResolveConf = false` to prevent auto-generation of that file. This deletes your `resolv.conf` file that is automatically generated when you run WSL, creates a new file and puts `nameserver 8.8.8.8`, then creates a `wsl.conf` file and adds `[network]` and `generateResolveConf = false` to prevent auto-generation of that file.
You can check the contents of the file by running: You can check the contents of the file by running:

View File

@ -33,7 +33,7 @@ nvm_install_dir() {
} }
nvm_latest_version() { nvm_latest_version() {
nvm_echo "v0.39.5" nvm_echo "v0.39.7"
} }
nvm_profile_is_bash_or_zsh() { nvm_profile_is_bash_or_zsh() {

6
nvm.sh
View File

@ -3565,7 +3565,7 @@ nvm() {
fi fi
else else
export PATH="${NEWPATH}" export PATH="${NEWPATH}"
command hash -r \hash -r
if [ "${NVM_SILENT:-0}" -ne 1 ]; then if [ "${NVM_SILENT:-0}" -ne 1 ]; then
nvm_echo "${NVM_DIR}/*/bin removed from \${PATH}" nvm_echo "${NVM_DIR}/*/bin removed from \${PATH}"
fi fi
@ -3697,7 +3697,7 @@ nvm() {
export MANPATH export MANPATH
fi fi
export PATH export PATH
command hash -r \hash -r
export NVM_BIN="${NVM_VERSION_DIR}/bin" export NVM_BIN="${NVM_VERSION_DIR}/bin"
export NVM_INC="${NVM_VERSION_DIR}/include/node" export NVM_INC="${NVM_VERSION_DIR}/include/node"
if [ "${NVM_SYMLINK_CURRENT-}" = true ]; then if [ "${NVM_SYMLINK_CURRENT-}" = true ]; then
@ -4226,7 +4226,7 @@ nvm() {
NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}" NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}"
;; ;;
"--version" | "-v") "--version" | "-v")
nvm_echo '0.39.5' nvm_echo '0.39.7'
;; ;;
"unload") "unload")
nvm deactivate >/dev/null 2>&1 nvm deactivate >/dev/null 2>&1

View File

@ -1,6 +1,6 @@
{ {
"name": "nvm", "name": "nvm",
"version": "0.39.5", "version": "0.39.7",
"description": "Node Version Manager - Simple bash script to manage multiple active node.js versions", "description": "Node Version Manager - Simple bash script to manage multiple active node.js versions",
"directories": { "directories": {
"test": "test" "test": "test"