[readme] update outdated Node.js version examples in nvm --help and the readme
Several "pick a recent version" examples cited EOL Node versions (4.2, 4.8.3, 5.9, 6.10.3, 8.x, 12.22.1, 14.x, 16.x, 18.x, and Iron's 20). Update them to current LTS lines (22.x/24.x), including the full `.nvmrc` walkthrough output, preserving the `--help` column alignment. Intentionally-historical references are left unchanged: the io.js migration examples, the `stable`/`unstable` alias notes, the Alpine version table, the source-build narrative, and the `--shared-zlib` example (which explicitly demonstrates installing an older version) Signed-off-by: Than Tibbetts <than@me.com> Co-authored-by: Than Tibbetts <than@me.com> Co-authored-by: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
1 parent
62adf80079
commit
11f7827dfc
2 files changed
+23
-23
No files matched your search
@@ -386,13 +386,13 @@ nvm install node # "node" is an alias for the latest version
|
|||||||
To install a specific version of node:
|
To install a specific version of node:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm install 14.7.0 # or 16.3.0, 12.22.1, etc
|
nvm install 22.11.0 # or 24.0.0, etc
|
||||||
```
|
```
|
||||||
|
|
||||||
To set an alias:
|
To set an alias:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm alias my_alias v14.4.0
|
nvm alias my_alias v22.11.0
|
||||||
```
|
```
|
||||||
Make sure that your alias does not contain any spaces or slashes.
|
Make sure that your alias does not contain any spaces or slashes.
|
||||||
|
|
||||||
@@ -435,16 +435,16 @@ nvm run node --version
|
|||||||
Or, you can run any arbitrary command in a subshell with the desired version of node:
|
Or, you can run any arbitrary command in a subshell with the desired version of node:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm exec 4.2 node --version
|
nvm exec 22.11 node --version
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also get the path to the executable to where it was installed:
|
You can also get the path to the executable to where it was installed:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm which 12.22
|
nvm which 22.11
|
||||||
```
|
```
|
||||||
|
|
||||||
In place of a version pointer like "14.7" or "16.3" or "12.22.1", you can use the following special default aliases with `nvm install`, `nvm use`, `nvm run`, `nvm exec`, `nvm which`, etc:
|
In place of a version pointer like "22" or "24.0" or "22.11.0", you can use the following special default aliases with `nvm install`, `nvm use`, `nvm run`, `nvm exec`, `nvm which`, etc:
|
||||||
|
|
||||||
- `node`: this installs the latest version of [`node`](https://nodejs.org/en/)
|
- `node`: this installs the latest version of [`node`](https://nodejs.org/en/)
|
||||||
- `iojs`: this installs the latest version of [`io.js`](https://iojs.org/en/)
|
- `iojs`: this installs the latest version of [`io.js`](https://iojs.org/en/)
|
||||||
@@ -544,7 +544,7 @@ This reinstalls all global packages from `22.20.0` into the currently-active ver
|
|||||||
If you've previously downloaded a node version (or it's still in the cache), you can install it without any network access using the `--offline` flag:
|
If you've previously downloaded a node version (or it's still in the cache), you can install it without any network access using the `--offline` flag:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm install --offline 14.7.0
|
nvm install --offline 22.11.0
|
||||||
```
|
```
|
||||||
|
|
||||||
This resolves versions using only locally installed versions and cached downloads. It will not attempt to download anything. This is useful in air-gapped environments, on planes, or when you want to avoid network latency.
|
This resolves versions using only locally installed versions and cached downloads. It will not attempt to download anything. This is useful in air-gapped environments, on planes, or when you want to avoid network latency.
|
||||||
@@ -668,10 +668,10 @@ To set a default Node version to be used in any new shell, use the alias 'defaul
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
nvm alias default node # this refers to the latest installed version of node
|
nvm alias default node # this refers to the latest installed version of node
|
||||||
nvm alias default 18 # this refers to the latest installed v18.x version of node
|
nvm alias default 22 # this refers to the latest installed v22.x version of node
|
||||||
nvm alias default 18.12 # this refers to the latest installed v18.12.x version of node
|
nvm alias default 22.11 # this refers to the latest installed v22.11.x version of node
|
||||||
nvm alias default --lts node # this refers to the latest installed LTS version of node
|
nvm alias default --lts node # this refers to the latest installed LTS version of node
|
||||||
nvm alias default --lts=iron 20 # this refers to the latest installed v20.x version of node from the "iron" LTS line
|
nvm alias default --lts=jod 22 # this refers to the latest installed v22.x version of node from the "jod" LTS line
|
||||||
```
|
```
|
||||||
|
|
||||||
nvm records the LTS status of every version each time it downloads the list of available versions, so `--lts` aliases know which installed versions are LTS.
|
nvm records the LTS status of every version each time it downloads the list of available versions, so `--lts` aliases know which installed versions are LTS.
|
||||||
@@ -683,7 +683,7 @@ To use a mirror of the node binaries, set `$NVM_NODEJS_ORG_MIRROR`:
|
|||||||
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
|
export NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
|
||||||
nvm install node
|
nvm install node
|
||||||
|
|
||||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 4.2
|
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist nvm install 22.11
|
||||||
```
|
```
|
||||||
|
|
||||||
To use a mirror of the io.js binaries, set `$NVM_IOJS_ORG_MIRROR`:
|
To use a mirror of the io.js binaries, set `$NVM_IOJS_ORG_MIRROR`:
|
||||||
@@ -744,10 +744,10 @@ Neither host is gapless, and both change over time; the `index.tab` at the root
|
|||||||
You can create a `.nvmrc` file containing a node version number (or any other string that `nvm` understands; see `nvm --help` for details) in the project root directory (or any parent directory).
|
You can create a `.nvmrc` file containing a node version number (or any other string that `nvm` understands; see `nvm --help` for details) in the project root directory (or any parent directory).
|
||||||
Afterwards, `nvm use`, `nvm install`, and `nvm which` will use the version specified in the `.nvmrc` file if no version is supplied on the command line; if no `.nvmrc` is found either, they exit with status `127`. (`nvm exec` and `nvm run` follow the same `.nvmrc` lookup, but currently fall back to the active node if neither resolves — treat that fallback as undefined behavior; pass an explicit version if you need predictable scripting.) If you want the currently active version, pass `current` explicitly (e.g. `nvm which current`) — `current` is not affected by `.nvmrc`.
|
Afterwards, `nvm use`, `nvm install`, and `nvm which` will use the version specified in the `.nvmrc` file if no version is supplied on the command line; if no `.nvmrc` is found either, they exit with status `127`. (`nvm exec` and `nvm run` follow the same `.nvmrc` lookup, but currently fall back to the active node if neither resolves — treat that fallback as undefined behavior; pass an explicit version if you need predictable scripting.) If you want the currently active version, pass `current` explicitly (e.g. `nvm which current`) — `current` is not affected by `.nvmrc`.
|
||||||
|
|
||||||
For example, to make nvm default to the latest 5.9 release, the latest LTS version, or the latest node version for the current directory:
|
For example, to make nvm default to the latest 22.11 release, the latest LTS version, or the latest node version for the current directory:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ echo "5.9" > .nvmrc
|
$ echo "22.11" > .nvmrc
|
||||||
|
|
||||||
$ echo "lts/*" > .nvmrc # to default to the latest LTS version
|
$ echo "lts/*" > .nvmrc # to default to the latest LTS version
|
||||||
|
|
||||||
@@ -760,21 +760,21 @@ Then when you run nvm use:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nvm use
|
$ nvm use
|
||||||
Found '/path/to/project/.nvmrc' with version <5.9>
|
Found '/path/to/project/.nvmrc' with version <22.11>
|
||||||
Now using node v5.9.1 (npm v3.7.3)
|
Now using node v22.11.0 (npm v10.9.0)
|
||||||
```
|
```
|
||||||
|
|
||||||
Running nvm install will also switch over to the correct version, but if the correct node version isn't already installed, it will install it for you.
|
Running nvm install will also switch over to the correct version, but if the correct node version isn't already installed, it will install it for you.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ nvm install
|
$ nvm install
|
||||||
Found '/path/to/project/.nvmrc' with version <5.9>
|
Found '/path/to/project/.nvmrc' with version <22.11>
|
||||||
Downloading and installing node v5.9.1...
|
Downloading and installing node v22.11.0...
|
||||||
Downloading https://nodejs.org/dist/v5.9.1/node-v5.9.1-linux-x64.tar.xz...
|
Downloading https://nodejs.org/dist/v22.11.0/node-v22.11.0-linux-x64.tar.xz...
|
||||||
#################################################################################### 100.0%
|
#################################################################################### 100.0%
|
||||||
Computing checksum with sha256sum
|
Computing checksum with sha256sum
|
||||||
Checksums matched!
|
Checksums matched!
|
||||||
Now using node v5.9.1 (npm v3.7.3)
|
Now using node v22.11.0 (npm v10.9.0)
|
||||||
```
|
```
|
||||||
|
|
||||||
`nvm use` et. al. will traverse directory structure upwards from the current directory looking for the `.nvmrc` file. In other words, running `nvm use` et. al. in any subdirectory of a directory with an `.nvmrc` will result in that `.nvmrc` being utilized.
|
`nvm use` et. al. will traverse directory structure upwards from the current directory looking for the `.nvmrc` file. In other words, running `nvm use` et. al. in any subdirectory of a directory with an `.nvmrc` will result in that `.nvmrc` being utilized.
|
||||||
|
|||||||
@@ -5185,11 +5185,11 @@ nvm() {
|
|||||||
nvm_echo ' nvm set-colors [<color codes>] Set five text colors using format "yMeBg". Available when supported.'
|
nvm_echo ' nvm set-colors [<color codes>] Set five text colors using format "yMeBg". Available when supported.'
|
||||||
nvm_print_color_legend
|
nvm_print_color_legend
|
||||||
nvm_echo 'Example:'
|
nvm_echo 'Example:'
|
||||||
nvm_echo ' nvm install 8.0.0 Install a specific version number'
|
nvm_echo ' nvm install 24.0.0 Install a specific version number'
|
||||||
nvm_echo ' nvm use 8.0 Use the latest available 8.0.x release'
|
nvm_echo ' nvm use 22.11 Use the latest available 22.11.x release'
|
||||||
nvm_echo ' nvm run 6.10.3 app.js Run app.js using node 6.10.3'
|
nvm_echo ' nvm run 22.11.0 app.js Run app.js using node 22.11.0'
|
||||||
nvm_echo ' nvm exec 4.8.3 node app.js Run `node app.js` with the PATH pointing to node 4.8.3'
|
nvm_echo ' nvm exec 24.0.0 node app.js Run `node app.js` with the PATH pointing to node 24.0.0'
|
||||||
nvm_echo ' nvm alias default 8.1.0 Set default node version on a shell'
|
nvm_echo ' nvm alias default 24.0.0 Set default node version on a shell'
|
||||||
nvm_echo ' nvm alias default node Always default to the latest available node version on a shell'
|
nvm_echo ' nvm alias default node Always default to the latest available node version on a shell'
|
||||||
nvm_echo
|
nvm_echo
|
||||||
nvm_echo ' nvm install node Install the latest available version'
|
nvm_echo ' nvm install node Install the latest available version'
|
||||||
|
|||||||
Reference in new issue
Block a user