Compare commits

...

20 Commits

Author SHA1 Message Date
Chris Seitz
6bd63b13c4
Merge 387d92cd4d into 74eb396099 2025-02-05 17:50:37 +07:00
Jordan Harband
74eb396099
[Dev Deps] update markdown-link-check 2025-02-04 12:37:59 -08:00
Chris Seitz
387d92cd4d
Merge pull request #1 from cseitz-forks/cseitz-nvm-no-help-1
Added NVM_NO_HELP flag to nvm.sh
2023-06-06 13:34:03 -04:00
Chris Seitz
85e1d29fa8
Added NVM_NO_HELP flag to nvm.sh
This allows you to prevent NVM from intercepting help calls.
2023-06-06 13:31:41 -04:00
Atsushi Yamamoto
9f520c97db
[Tests] nvm exec/nvm run: add --silent tests
Co-authored-by: Atsushi Yamamoto <yamaatsushi927@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2016-10-11 23:43:10 -07:00
Jordan Harband
e5521cfd3c
[actions] release test needs git tags 2025-02-04 08:44:48 -08:00
Jérémy GAU
247ed8a186
[readme] fix --no-use example 2024-11-28 20:33:25 +01:00
Jessica Wagantall
14507f807f
[Tests] migrate installation_iojs test suite to GitHub Actions
Remove equivalent TravisCI entries

Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
2024-11-21 15:14:14 -08:00
Jessica Wagantall
6135555b40
[Tests] Migrate slow test suite from Travis CI
Signed-off-by: Jessica Wagantall <jwagantall@linuxfoundation.org>
2024-11-14 16:11:04 -08:00
Chris de Almeida
d90a7910db
[readme] update copyright notice 2025-01-10 14:41:50 -06:00
Andy Gimblett
8c30ac633b
[readme] note zsh-nvm's AUTO_USE option 2021-12-01 14:55:38 +00:00
Nicola Lanzoni
ecdc865a5a
[readme] add note about reloading zshrc after editing 2023-03-09 09:39:55 -03:00
Asad Akbar
9bcbbef4eb
[readme] Update shell profile file install notes
* Adds a note for how to fix the issue when the install script is not   updating the correct profile file.
2020-06-19 16:36:09 -07:00
Björn Holm
b77fcec399
[readme] add docker tips
- covers installation using BASH_ENV

Co-authored-by: Christopher Dieringer <cdaringe@users.noreply.github.com>
Co-authored-by: Björn Holm <blollle@gmail.com>
2022-11-14 00:16:13 +01:00
Andrew Chang-DeWitt
287d535f2c
[readme] remove avn from readme
`avn` is archived ([see repo](https://github.com/direnv/direnv)) and should probably no longer be recommended by nvm.

This also adds a solution using `direnv` and proposes a possible `.envrc` to use.
See [wbyoung/avn#109](https://github.com/wbyoung/avn/issues/109#issuecomment-1281865585) for more suggested `.envrc` files.
2024-11-13 14:41:39 -06:00
Kid
572c757f6d
[readme] fnm -> nvm.fish 2021-07-18 18:32:40 +08:00
Jordan Harband
1d39e35bd3
[Tests] temporarily skip this failing travis test to unblock progress 2025-02-03 10:50:19 -08:00
Jordan Harband
19f452ba0f
[Fix] avoid bash-specific syntax
Fixes #3499
2024-12-19 22:21:09 -08:00
Jordan Harband
b9b0ea8020
[Fix] install-latest-npm: npm v11 is out 2024-12-16 10:03:18 -08:00
Jordan Harband
dae1427f7e
[actions] TOC: use latest LTS node 2024-11-22 21:44:36 -10:00
12 changed files with 111 additions and 31 deletions

View File

@ -37,6 +37,11 @@ jobs:
matrix: matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }} node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
include: include:
- node-version: "21"
- node-version: "20.5"
- node-version: "20.4"
- node-version: "14.17"
- node-version: "14.16"
- node-version: "9.2" - node-version: "9.2"
- node-version: "9.1" - node-version: "9.1"
- node-version: "9.0" - node-version: "9.0"

View File

@ -19,6 +19,8 @@ jobs:
raw.githubusercontent.com:443 raw.githubusercontent.com:443
registry.npmjs.org:443 registry.npmjs.org:443
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: "14" node-version: "14"

View File

@ -31,6 +31,8 @@ jobs:
suite: suite:
- install_script - install_script
- sourcing - sourcing
- slow
- installation_iojs
shell: shell:
- sh - sh
- bash - bash

View File

@ -20,6 +20,7 @@ jobs:
allowed-endpoints: allowed-endpoints:
github.com:443 github.com:443
registry.npmjs.org:443 registry.npmjs.org:443
api.github.com:443
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
# https://github.com/actions/checkout/issues/217#issue-599945005 # https://github.com/actions/checkout/issues/217#issue-599945005
@ -30,7 +31,7 @@ jobs:
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: '16' node-version: 'lts/*'
- run: npm install - run: npm install
- run: npm run doctoc - run: npm run doctoc
- name: commit changes - name: commit changes

View File

@ -87,18 +87,8 @@ env:
- SHELL=bash TEST_SUITE=fast - SHELL=bash TEST_SUITE=fast
- SHELL=zsh TEST_SUITE=fast - SHELL=zsh TEST_SUITE=fast
# - SHELL=ksh TEST_SUITE=fast # - SHELL=ksh TEST_SUITE=fast
- SHELL=sh TEST_SUITE=slow
- SHELL=dash TEST_SUITE=slow
- SHELL=bash TEST_SUITE=slow
- SHELL=zsh TEST_SUITE=slow
# - SHELL=ksh TEST_SUITE=slow
- SHELL=sh TEST_SUITE=installation_iojs
- SHELL=sh TEST_SUITE=installation_iojs WITHOUT_CURL=1 - SHELL=sh TEST_SUITE=installation_iojs WITHOUT_CURL=1
- SHELL=dash TEST_SUITE=installation_iojs
- SHELL=dash TEST_SUITE=installation_iojs WITHOUT_CURL=1 - SHELL=dash TEST_SUITE=installation_iojs WITHOUT_CURL=1
- SHELL=bash TEST_SUITE=installation_iojs
- SHELL=bash TEST_SUITE=installation_iojs WITHOUT_CURL=1 - SHELL=bash TEST_SUITE=installation_iojs WITHOUT_CURL=1
- SHELL=zsh TEST_SUITE=installation_iojs
- SHELL=zsh TEST_SUITE=installation_iojs WITHOUT_CURL=1 - SHELL=zsh TEST_SUITE=installation_iojs WITHOUT_CURL=1
# - SHELL=ksh TEST_SUITE=installation_iojs
# - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1 # - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1

View File

@ -91,16 +91,20 @@ RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# Switch to user "nvm" from now # Switch to user "nvm" from now
USER nvm USER nvm
# Create a script file sourced by both interactive and non-interactive bash shells
ENV BASH_ENV /home/nvm/.bash_env
RUN touch "$BASH_ENV"
RUN echo '. "$BASH_ENV"' >> "$HOME/.bashrc"
# nvm # nvm
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> "$HOME/.bashrc" RUN echo 'export NVM_DIR="$HOME/.nvm"' >> "$BASH_ENV"
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "$HOME/.bashrc" RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "$BASH_ENV"
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$HOME/.bashrc" RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$BASH_ENV"
# nodejs and tools # nodejs and tools
RUN bash -c 'source $HOME/.nvm/nvm.sh && \ RUN nvm install node
nvm install node && \ RUN npm install -g doctoc urchin eclint dockerfile_lint
npm install -g doctoc urchin eclint dockerfile_lint && \ RUN npm install --prefix "$HOME/.nvm/"
npm install --prefix "$HOME/.nvm/"'
# Set WORKDIR to nvm directory # Set WORKDIR to nvm directory
WORKDIR /home/nvm/.nvm WORKDIR /home/nvm/.nvm

View File

@ -18,6 +18,7 @@
- [Installing and Updating](#installing-and-updating) - [Installing and Updating](#installing-and-updating)
- [Install & Update Script](#install--update-script) - [Install & Update Script](#install--update-script)
- [Additional Notes](#additional-notes) - [Additional Notes](#additional-notes)
- [Installing in Docker](#installing-in-docker)
- [Troubleshooting on Linux](#troubleshooting-on-linux) - [Troubleshooting on Linux](#troubleshooting-on-linux)
- [Troubleshooting on macOS](#troubleshooting-on-macos) - [Troubleshooting on macOS](#troubleshooting-on-macos)
- [Ansible](#ansible) - [Ansible](#ansible)
@ -108,7 +109,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`). 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 (`~/.bashrc`, `~/.bash_profile`, `~/.zshrc`, or `~/.profile`). If you find the install script is updating the wrong profile file, set the `$PROFILE` env var to the profile files path, and then rerun the installation script.
<a id="profile_snippet"></a> <a id="profile_snippet"></a>
```sh ```sh
@ -120,7 +121,12 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr
- If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub> - If the environment variable `$XDG_CONFIG_HOME` is present, it will place the `nvm` files there.</sub>
- You can add `--no-use` to the end of the above script (...`nvm.sh --no-use`) to postpone using `nvm` until you manually [`use`](#usage) it. - You can add `--no-use` to the end of the above script to postpone using `nvm` until you manually [`use`](#usage) it:
```sh
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm, without auto-using the default version
```
- You can customize the install source, directory, profile, and version using the `NVM_SOURCE`, `NVM_DIR`, `PROFILE`, and `NODE_VERSION` variables. - 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="path/to/nvm"`. Ensure that the `NVM_DIR` does not contain a trailing slash. Eg: `curl ... | NVM_DIR="path/to/nvm"`. Ensure that the `NVM_DIR` does not contain a trailing slash.
@ -129,6 +135,25 @@ Eg: `curl ... | NVM_DIR="path/to/nvm"`. Ensure that the `NVM_DIR` does not conta
- 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.40.1/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.40.1/install.sh | bash'`
#### Installing in Docker
When invoking bash as a non-interactive shell, like in a Docker container, none of the regular profile files are sourced. In order to use `nvm`, `node`, and `npm` like normal, you can instead specify the special `BASH_ENV` variable, which bash sources when invoked non-interactively.
```Dockerfile
# Use bash for the shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Create a script file sourced by both interactive and non-interactive bash shells
ENV BASH_ENV /home/user/.bash_env
RUN touch "${BASH_ENV}"
RUN echo '. "${BASH_ENV}"' >> ~/.bashrc
# Download and install nvm
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | PROFILE="${BASH_ENV}" bash
RUN echo node > .nvmrc
RUN nvm install
```
#### Troubleshooting on Linux #### Troubleshooting on Linux
On Linux, after running the install script, if you get `nvm: command not found` or see no feedback from your terminal after you type `command -v nvm`, simply close your current terminal, open a new terminal, and try verifying again. On Linux, after running the install script, if you get `nvm: command not found` or see no feedback from your terminal after you type `command -v nvm`, simply close your current terminal, open a new terminal, and try verifying again.
@ -207,7 +232,7 @@ If you're running a system without prepackaged binary available, which means you
- [bass](https://github.com/edc/bass) allows you 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 - [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
- [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 - [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
- [fnm](https://github.com/fisherman/fnm) - [fisherman](https://github.com/fisherman/fisherman)-based version manager for fish - [nvm.fish](https://github.com/jorgebucaran/nvm.fish) - The Node.js version manager you'll adore, crafted just for Fish
- [fish-nvm](https://github.com/FabioAntunes/fish-nvm) - Wrapper around nvm for fish, delays sourcing nvm until it's actually used. - [fish-nvm](https://github.com/FabioAntunes/fish-nvm) - Wrapper around nvm for fish, delays sourcing nvm until it's actually used.
**Note:** We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket: **Note:** We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:
@ -227,7 +252,7 @@ If you're running a system without prepackaged binary available, which means you
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. 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 upgrade` to upgrade. **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 ([you can set](https://github.com/lukechilds/zsh-nvm#auto-use) `NVM_AUTO_USE=true` to have it automatically detect and use `.nvmrc` files).
**Note:** Git versions before v1.7 may face a problem of cloning `nvm` source from GitHub via https protocol, and there is also different behavior of git before v1.6, and git prior to [v1.17.10](https://github.com/git/git/commit/5a7d5b683f869d3e3884a89775241afa515da9e7) can not clone tags, so the minimum required git version is v1.7.10. If you are interested in the problem we mentioned here, please refer to GitHub's [HTTPS cloning errors](https://help.github.com/articles/https-cloning-errors/) article. **Note:** Git versions before v1.7 may face a problem of cloning `nvm` source from GitHub via https protocol, and there is also different behavior of git before v1.6, and git prior to [v1.17.10](https://github.com/git/git/commit/5a7d5b683f869d3e3884a89775241afa515da9e7) can not clone tags, so the minimum required git version is v1.7.10. If you are interested in the problem we mentioned here, please refer to GitHub's [HTTPS cloning errors](https://help.github.com/articles/https-cloning-errors/) article.
@ -588,9 +613,7 @@ Run [`npx nvmrc`](https://npmjs.com/nvmrc) to validate an `.nvmrc` file. If that
### Deeper Shell Integration ### Deeper Shell Integration
You can use [`avn`](https://github.com/wbyoung/avn) to deeply integrate into your shell and automatically invoke `nvm` when changing directories. `avn` is **not** supported by the `nvm` maintainers. Please [report issues to the `avn` team](https://github.com/wbyoung/avn/issues/new). You can use [`nvshim`](https://github.com/iamogbz/nvshim) to shim the `node`, `npm`, and `npx` bins to automatically use the `nvm` config in the current directory. `nvshim` is **not** supported by the `nvm` maintainers. Please [report issues to the `nvshim` team](https://github.com/iamogbz/nvshim/issues/new).
You can also use [`nvshim`](https://github.com/iamogbz/nvshim) to shim the `node`, `npm`, and `npx` bins to automatically use the `nvm` config in the current directory. `nvshim` is **not** supported by the `nvm` maintainers. Please [report issues to the `nvshim` team](https://github.com/iamogbz/nvshim/issues/new).
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.
@ -685,6 +708,8 @@ add-zsh-hook chpwd load-nvmrc
load-nvmrc load-nvmrc
``` ```
After saving the file, run `source ~/.zshrc` to reload the configuration with the latest changes made.
##### fish ##### fish
This requires that you have [bass](https://github.com/edc/bass) installed. This requires that you have [bass](https://github.com/edc/bass) installed.
@ -1088,6 +1113,5 @@ See [LICENSE.md](./LICENSE.md).
## Copyright notice ## Copyright notice
Copyright [OpenJS Foundation](https://openjsf.org) and `nvm` contributors. All rights reserved. The [OpenJS Foundation](https://openjsf.org) has registered trademarks and uses trademarks. For a list of trademarks of the [OpenJS Foundation](https://openjsf.org), please see our [Trademark Policy](https://trademark-policy.openjsf.org/) and [Trademark List](https://trademark-list.openjsf.org/). Node.js is a trademark of Joyent, Inc. and is used with its permission. Trademarks and logos not indicated on the [list of OpenJS Foundation trademarks](https://trademark-list.openjsf.org) are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them. Copyright [OpenJS Foundation](https://openjsf.org) and `nvm` contributors. All rights reserved. The [OpenJS Foundation](https://openjsf.org) has registered trademarks and uses trademarks. For a list of trademarks of the [OpenJS Foundation](https://openjsf.org), please see our [Trademark Policy](https://trademark-policy.openjsf.org/) and [Trademark List](https://trademark-list.openjsf.org/). Trademarks and logos not indicated on the [list of OpenJS Foundation trademarks](https://trademark-list.openjsf.org) are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
[The OpenJS Foundation](https://openjsf.org/) | [Terms of Use](https://terms-of-use.openjsf.org/) | [Privacy Policy](https://privacy-policy.openjsf.org/) | [Bylaws](https://bylaws.openjsf.org/) | [Code of Conduct](https://code-of-conduct.openjsf.org) | [Trademark Policy](https://trademark-policy.openjsf.org/) | [Trademark List](https://trademark-list.openjsf.org/) | [Cookie Policy](https://www.linuxfoundation.org/cookies/)
[The OpenJS Foundation](https://openjsf.org/) | [Terms of Use](https://terms-of-use.openjsf.org/) | [Privacy Policy](https://privacy-policy.openjsf.org/) | [OpenJS Foundation Bylaws](https://bylaws.openjsf.org/) | [Trademark Policy](https://trademark-policy.openjsf.org/) | [Trademark List](https://trademark-list.openjsf.org/) | [Cookie Policy](https://www.linuxfoundation.org/cookies/)

28
nvm.sh
View File

@ -354,6 +354,21 @@ nvm_install_latest_npm() {
if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then
NVM_IS_20_5_OR_ABOVE=1 NVM_IS_20_5_OR_ABOVE=1
fi fi
local NVM_IS_20_17_or_ABOVE
NVM_IS_20_17_or_ABOVE=0
if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater 20.17.0 "${NODE_VERSION}"; then
NVM_IS_20_17_or_ABOVE=1
fi
local NVM_IS_21_OR_ABOVE
NVM_IS_21_OR_ABOVE=0
if [ $NVM_IS_20_17_or_ABOVE -eq 1 ] && nvm_version_greater 21.0.0 "${NODE_VERSION}"; then
NVM_IS_21_OR_ABOVE=1
fi
local NVM_IS_22_9_OR_ABOVE
NVM_IS_22_9_OR_ABOVE=0
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater 22.9.0 "${NODE_VERSION}"; then
NVM_IS_22_9_OR_ABOVE=1
fi
if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || { if [ $NVM_IS_4_4_OR_BELOW -eq 1 ] || {
[ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \ [ $NVM_IS_5_OR_ABOVE -eq 1 ] && nvm_version_greater 5.10.0 "${NODE_VERSION}"; \
@ -399,8 +414,15 @@ nvm_install_latest_npm() {
[ $NVM_IS_18_17_OR_ABOVE -eq 0 ] \ [ $NVM_IS_18_17_OR_ABOVE -eq 0 ] \
|| { [ $NVM_IS_19_OR_ABOVE -eq 1 ] && [ $NVM_IS_20_5_OR_ABOVE -eq 0 ]; } \ || { [ $NVM_IS_19_OR_ABOVE -eq 1 ] && [ $NVM_IS_20_5_OR_ABOVE -eq 0 ]; } \
; then ; then
# TODO: 10.8.3 can run on 16.20.2?? https://github.com/nodejs/Release/issues/884#issuecomment-2558077691
nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`' nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`'
$NVM_NPM_CMD install -g npm@9 $NVM_NPM_CMD install -g npm@9
elif \
[ $NVM_IS_20_17_or_ABOVE -eq 0 ] \
|| { [ $NVM_IS_21_OR_ABOVE -eq 1 ] && [ $NVM_IS_22_9_OR_ABOVE -eq 0 ]; } \
; then
nvm_echo '* `npm` `v10.x` is the last version that works on `node` `< v20.17`, `v21`, or `v22.0` - `v22.8`'
$NVM_NPM_CMD install -g npm@10
else else
nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!' nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!'
$NVM_NPM_CMD install -g npm $NVM_NPM_CMD install -g npm
@ -422,8 +444,7 @@ fi
if [ -z "${NVM_DIR-}" ]; then if [ -z "${NVM_DIR-}" ]; then
# shellcheck disable=SC2128 # shellcheck disable=SC2128
if [ -n "${BASH_SOURCE-}" ]; then if [ -n "${BASH_SOURCE-}" ]; then
# shellcheck disable=SC2169,SC3054 NVM_SCRIPT_SOURCE="${BASH_SOURCE}"
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" >/dev/null && \pwd)" NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" >/dev/null && \pwd)"
@ -3015,6 +3036,9 @@ nvm() {
--) break ;; --) break ;;
'-h'|'help'|'--help') '-h'|'help'|'--help')
NVM_NO_COLORS="" NVM_NO_COLORS=""
if [[ "$NVM_NO_HELP" -eq 1 ]]; then
break;
fi
for j in "$@"; do for j in "$@"; do
if [ "${j}" = '--no-colors' ]; then if [ "${j}" = '--no-colors' ]; then
NVM_NO_COLORS="${j}" NVM_NO_COLORS="${j}"

View File

@ -45,7 +45,7 @@
"dockerfile_lint": "^0.3.4", "dockerfile_lint": "^0.3.4",
"doctoc": "^2.2.1", "doctoc": "^2.2.1",
"eclint": "^2.8.1", "eclint": "^2.8.1",
"markdown-link-check": "^3.12.2", "markdown-link-check": "^3.13.6",
"replace": "^1.2.2", "replace": "^1.2.2",
"semver": "^7.6.3", "semver": "^7.6.3",
"urchin": "^0.0.5" "urchin": "^0.0.5"

View File

@ -0,0 +1,28 @@
#!/bin/sh
set -ex
die () { echo "$@" ; exit 1; }
. ../../../nvm.sh
echo "0.10.7" > .nvmrc
# Check nvm run without --silent
OUTPUT="$(nvm run --version)"
EXPECTED_OUTPUT="Found '${PWD}/.nvmrc' with version <0.10.7>
Running node v0.10.7 (npm v1.2.21)
v0.10.7"
[ ">${OUTPUT}<" = ">${EXPECTED_OUTPUT}<" ] \
|| die "\`nvm run\` failed to run; did not match with the .nvmrc version; got >${OUTPUT}<"
OUTPUT="$(nvm run --silent --version)"
EXPECTED_OUTPUT="v0.10.7"
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] \
|| die "\`nvm run --silent\` failed to run silently; expected no output, got >${OUTPUT}<"
# Output shouldn't be silent if --silent flag is not at the third argument position
OUTPUT="$(nvm run --version --silent)"
EXPECTED_OUTPUT=""
[ "${OUTPUT}" != "${EXPECTED_OUTPUT}" ] \
|| die "\`nvm run --version --silent\` should not be silent; expected >${OUTPUT}<, got no output"