From dae1427f7e046184bbb1c22a75f3f8d127206513 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 22 Nov 2024 21:44:36 -1000 Subject: [PATCH 01/25] [actions] TOC: use latest LTS node --- .github/workflows/toc.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/toc.yml b/.github/workflows/toc.yml index 8772bcc..715f03b 100644 --- a/.github/workflows/toc.yml +++ b/.github/workflows/toc.yml @@ -20,6 +20,7 @@ jobs: allowed-endpoints: github.com:443 registry.npmjs.org:443 + api.github.com:443 - uses: actions/checkout@v4 with: # https://github.com/actions/checkout/issues/217#issue-599945005 @@ -30,7 +31,7 @@ jobs: - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - uses: actions/setup-node@v4 with: - node-version: '16' + node-version: 'lts/*' - run: npm install - run: npm run doctoc - name: commit changes From b9b0ea802068630b30e94414a85d9a7b2a76fe68 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 16 Dec 2024 10:03:18 -0800 Subject: [PATCH 02/25] [Fix] `install-latest-npm`: npm v11 is out --- .github/workflows/latest-npm.yml | 5 +++++ nvm.sh | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.github/workflows/latest-npm.yml b/.github/workflows/latest-npm.yml index b368080..2f25052 100644 --- a/.github/workflows/latest-npm.yml +++ b/.github/workflows/latest-npm.yml @@ -37,6 +37,11 @@ jobs: matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} 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.1" - node-version: "9.0" diff --git a/nvm.sh b/nvm.sh index ed0e0b3..b23723c 100755 --- a/nvm.sh +++ b/nvm.sh @@ -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 NVM_IS_20_5_OR_ABOVE=1 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 ] || { [ $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_19_OR_ABOVE -eq 1 ] && [ $NVM_IS_20_5_OR_ABOVE -eq 0 ]; } \ ; 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_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 nvm_echo '* Installing latest `npm`; if this does not work on your node version, please report a bug!' $NVM_NPM_CMD install -g npm From 19f452ba0f2bb665c0ffb5bef29865183c67a597 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 19 Dec 2024 22:21:09 -0800 Subject: [PATCH 03/25] [Fix] avoid bash-specific syntax Fixes #3499 --- nvm.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index b23723c..5aba5d4 100755 --- a/nvm.sh +++ b/nvm.sh @@ -444,8 +444,7 @@ fi if [ -z "${NVM_DIR-}" ]; then # shellcheck disable=SC2128 if [ -n "${BASH_SOURCE-}" ]; then - # shellcheck disable=SC2169,SC3054 - NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}" + NVM_SCRIPT_SOURCE="${BASH_SOURCE}" fi # shellcheck disable=SC2086 NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" >/dev/null && \pwd)" From 1d39e35bd3db9249508dc45e9fdd5fc8b58f6b96 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 3 Feb 2025 10:50:19 -0800 Subject: [PATCH 04/25] [Tests] temporarily skip this failing travis test to unblock progress --- ...g 'nvm uninstall' with incorrect file permissions fails nicely | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 test/slow/nvm uninstall/Running 'nvm uninstall' with incorrect file permissions fails nicely diff --git a/test/slow/nvm uninstall/Running 'nvm uninstall' with incorrect file permissions fails nicely b/test/slow/nvm uninstall/Running 'nvm uninstall' with incorrect file permissions fails nicely old mode 100755 new mode 100644 From 572c757f6dad0de16a27de4a1f7ebc713368afde Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Sun, 18 Jul 2021 18:32:40 +0800 Subject: [PATCH 05/25] [readme] fnm -> nvm.fish --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 89fc5a8..d7a644b 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,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 - [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 - - [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. **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: From 287d535f2c58007445e57773d2bbf56cabec0b56 Mon Sep 17 00:00:00 2001 From: Andrew Chang-DeWitt <11323923+andrew-chang-dewitt@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:41:39 -0600 Subject: [PATCH 06/25] [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. --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d7a644b..4d152d1 100644 --- a/README.md +++ b/README.md @@ -588,9 +588,7 @@ Run [`npx nvmrc`](https://npmjs.com/nvmrc) to validate an `.nvmrc` file. If that ### 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 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). +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). 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. From b77fcec399d3c21645116263ce6212c137c13097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Holm?= Date: Mon, 14 Nov 2022 00:16:13 +0100 Subject: [PATCH 07/25] [readme] add docker tips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - covers installation using BASH_ENV Co-authored-by: Christopher Dieringer Co-authored-by: Björn Holm --- Dockerfile | 18 +++++++++++------- README.md | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index d95bb13..97ff98c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -91,16 +91,20 @@ RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers # Switch to user "nvm" from now 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 -RUN echo 'export NVM_DIR="$HOME/.nvm"' >> "$HOME/.bashrc" -RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "$HOME/.bashrc" -RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$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' >> "$BASH_ENV" +RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$BASH_ENV" # nodejs and tools -RUN bash -c 'source $HOME/.nvm/nvm.sh && \ - nvm install node && \ - npm install -g doctoc urchin eclint dockerfile_lint && \ - npm install --prefix "$HOME/.nvm/"' +RUN nvm install node +RUN npm install -g doctoc urchin eclint dockerfile_lint +RUN npm install --prefix "$HOME/.nvm/" # Set WORKDIR to nvm directory WORKDIR /home/nvm/.nvm diff --git a/README.md b/README.md index 4d152d1..291fa42 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ - [Installing and Updating](#installing-and-updating) - [Install & Update Script](#install--update-script) - [Additional Notes](#additional-notes) + - [Installing in Docker](#installing-in-docker) - [Troubleshooting on Linux](#troubleshooting-on-linux) - [Troubleshooting on macOS](#troubleshooting-on-macos) - [Ansible](#ansible) @@ -129,6 +130,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'` +#### 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 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. From 9bcbbef4eb7dc9c8537ad32a9b58bdee0c6b9e8c Mon Sep 17 00:00:00 2001 From: Asad Akbar Date: Fri, 19 Jun 2020 16:36:09 -0700 Subject: [PATCH 08/25] [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. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 291fa42..8719761 100644 --- a/README.md +++ b/README.md @@ -109,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 ``` -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 file’s path, and then rerun the installation script. ```sh From ecdc865a5a533d8eb5079b290c410ab8a959e7dc Mon Sep 17 00:00:00 2001 From: Nicola Lanzoni Date: Thu, 9 Mar 2023 09:39:55 -0300 Subject: [PATCH 09/25] [readme] add note about reloading zshrc after editing --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8719761..6394577 100644 --- a/README.md +++ b/README.md @@ -703,6 +703,8 @@ add-zsh-hook chpwd load-nvmrc load-nvmrc ``` +After saving the file, run `source ~/.zshrc` to reload the configuration with the latest changes made. + ##### fish This requires that you have [bass](https://github.com/edc/bass) installed. From 8c30ac633b90a8376dc8e5372a27befc1b7f30db Mon Sep 17 00:00:00 2001 From: Andy Gimblett Date: Wed, 1 Dec 2021 14:55:38 +0000 Subject: [PATCH 10/25] [readme] note zsh-nvm's AUTO_USE option --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6394577..57f320d 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,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. -**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. From d90a7910db093fde559611ffe79f5f2af0c3ad30 Mon Sep 17 00:00:00 2001 From: Chris de Almeida Date: Fri, 10 Jan 2025 14:41:50 -0600 Subject: [PATCH 11/25] [readme] update copyright notice --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 57f320d..db40157 100644 --- a/README.md +++ b/README.md @@ -1108,6 +1108,5 @@ See [LICENSE.md](./LICENSE.md). ## 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. - -[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/) +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/) From 6135555b4081f9ac195215c62009201e646eaa19 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Thu, 14 Nov 2024 16:11:04 -0800 Subject: [PATCH 12/25] [Tests] Migrate slow test suite from Travis CI Signed-off-by: Jessica Wagantall --- .github/workflows/tests.yml | 1 + .travis.yml | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3e92ec7..81faaf4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,6 +31,7 @@ jobs: suite: - install_script - sourcing + - slow shell: - sh - bash diff --git a/.travis.yml b/.travis.yml index 07cada9..2cb54f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,11 +87,6 @@ env: - SHELL=bash TEST_SUITE=fast - SHELL=zsh 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=dash TEST_SUITE=installation_iojs From 14507f807f749f7a215e89af740354ae7efa41ee Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Thu, 21 Nov 2024 15:14:14 -0800 Subject: [PATCH 13/25] [Tests] migrate `installation_iojs` test suite to GitHub Actions Remove equivalent TravisCI entries Signed-off-by: Jessica Wagantall --- .github/workflows/tests.yml | 1 + .travis.yml | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 81faaf4..4bc1121 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,6 +32,7 @@ jobs: - install_script - sourcing - slow + - installation_iojs shell: - sh - bash diff --git a/.travis.yml b/.travis.yml index 2cb54f0..ed22ae1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,13 +87,8 @@ env: - SHELL=bash TEST_SUITE=fast - SHELL=zsh TEST_SUITE=fast # - SHELL=ksh TEST_SUITE=fast - - SHELL=sh TEST_SUITE=installation_iojs - 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=bash TEST_SUITE=installation_iojs - 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=ksh TEST_SUITE=installation_iojs # - SHELL=ksh TEST_SUITE=installation_iojs WITHOUT_CURL=1 From 247ed8a1860560b20149265e3ff094f2cb40e7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81re=CC=81my=20GAU?= Date: Thu, 28 Nov 2024 20:33:25 +0100 Subject: [PATCH 14/25] [readme] fix `--no-use` example --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db40157..7806773 100644 --- a/README.md +++ b/README.md @@ -121,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. -- 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. Eg: `curl ... | NVM_DIR="path/to/nvm"`. Ensure that the `NVM_DIR` does not contain a trailing slash. From e5521cfd3ca26ae1bc5c7a02ca3d907af4d72e2f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Feb 2025 08:44:48 -0800 Subject: [PATCH 15/25] [actions] release test needs git tags --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84fe2d8..d7c3b7f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,8 @@ jobs: raw.githubusercontent.com:443 registry.npmjs.org:443 - uses: actions/checkout@v4 + with: + fetch-tags: true - uses: actions/setup-node@v4 with: node-version: "14" From 9f520c97db2ca53f3714d14c3a3f501098052f12 Mon Sep 17 00:00:00 2001 From: Atsushi Yamamoto Date: Tue, 11 Oct 2016 23:43:10 -0700 Subject: [PATCH 16/25] [Tests] `nvm exec`/`nvm run`: add `--silent` tests Co-authored-by: Atsushi Yamamoto Co-authored-by: Jordan Harband --- ...> Running 'nvm exec --silent' should work} | 0 .../Running 'nvm run --silent' should work | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+) rename test/slow/nvm exec/{Preamble works and respects 'silent' flag => Running 'nvm exec --silent' should work} (100%) create mode 100755 test/slow/nvm run/Running 'nvm run --silent' should work diff --git a/test/slow/nvm exec/Preamble works and respects 'silent' flag b/test/slow/nvm exec/Running 'nvm exec --silent' should work similarity index 100% rename from test/slow/nvm exec/Preamble works and respects 'silent' flag rename to test/slow/nvm exec/Running 'nvm exec --silent' should work diff --git a/test/slow/nvm run/Running 'nvm run --silent' should work b/test/slow/nvm run/Running 'nvm run --silent' should work new file mode 100755 index 0000000..38db032 --- /dev/null +++ b/test/slow/nvm run/Running 'nvm run --silent' should work @@ -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" From 74eb3960996576cd2f8ca8709574fc46e4c4f923 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Feb 2025 12:37:59 -0800 Subject: [PATCH 17/25] [Dev Deps] update `markdown-link-check` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 09f354e..a616e40 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dockerfile_lint": "^0.3.4", "doctoc": "^2.2.1", "eclint": "^2.8.1", - "markdown-link-check": "^3.12.2", + "markdown-link-check": "^3.13.6", "replace": "^1.2.2", "semver": "^7.6.3", "urchin": "^0.0.5" From 06a91793091ee788163a6ecb051da1754c9885ae Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Feb 2025 15:55:10 -0800 Subject: [PATCH 18/25] [Refactor] combine `sed -e` invocations/arguments --- nvm.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/nvm.sh b/nvm.sh index 5aba5d4..2800927 100755 --- a/nvm.sh +++ b/nvm.sh @@ -136,15 +136,17 @@ nvm_download() { eval "curl -q --fail ${CURL_COMPRESSED_FLAG:-} ${CURL_HEADER_FLAG:-} ${NVM_DOWNLOAD_ARGS}" elif nvm_has "wget"; then # Emulate curl with wget - ARGS=$(nvm_echo "$@" | command sed -e 's/--progress-bar /--progress=bar /' \ - -e 's/--compressed //' \ - -e 's/--fail //' \ - -e 's/-L //' \ - -e 's/-I /--server-response /' \ - -e 's/-s /-q /' \ - -e 's/-sS /-nv /' \ - -e 's/-o /-O /' \ - -e 's/-C - /-c /') + ARGS=$(nvm_echo "$@" | command sed " + s/--progress-bar /--progress=bar / + s/--compressed // + s/--fail // + s/-L // + s/-I /--server-response / + s/-s /-q / + s/-sS /-nv / + s/-o /-O / + s/-C - /-c / + ") if [ -n "${NVM_AUTH_HEADER:-}" ]; then ARGS="${ARGS} --header \"${NVM_AUTH_HEADER}\"" @@ -2732,7 +2734,7 @@ nvm_npm_global_modules() { local NPMLIST local VERSION VERSION="$1" - NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed 1,1d | nvm_grep -v 'UNMET PEER DEPENDENCY') + NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed -e '1d' -e '/UNMET PEER DEPENDENCY/d') local INSTALLS INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs) From 759f70f1967c56e0ce9b8f51a6c0b33efdea869b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 4 Feb 2025 22:45:35 -0800 Subject: [PATCH 19/25] [Refactor] prefer `case` over if/else chains --- nvm.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/nvm.sh b/nvm.sh index 2800927..736fb8e 100755 --- a/nvm.sh +++ b/nvm.sh @@ -1415,11 +1415,11 @@ nvm_add_iojs_prefix() { nvm_strip_iojs_prefix() { local NVM_IOJS_PREFIX NVM_IOJS_PREFIX="$(nvm_iojs_prefix)" - if [ "${1-}" = "${NVM_IOJS_PREFIX}" ]; then - nvm_echo - else - nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" - fi + + case "${1-}" in + "${NVM_IOJS_PREFIX}") nvm_echo ;; + *) nvm_echo "${1#"${NVM_IOJS_PREFIX}"-}" ;; + esac } nvm_ls() { @@ -1551,12 +1551,15 @@ nvm_ls() { fi if [ "${NVM_ADD_SYSTEM-}" = true ]; then - if [ -z "${PATTERN}" ] || [ "${PATTERN}" = 'v' ]; then - VERSIONS="${VERSIONS} + case "${PATTERN}" in + '' | v) + VERSIONS="${VERSIONS} system" - elif [ "${PATTERN}" = 'system' ]; then - VERSIONS="system" - fi + ;; + system) + VERSIONS="system" + ;; + esac fi if [ -z "${VERSIONS}" ]; then @@ -1690,7 +1693,7 @@ EOF LTS="${LTS#lts/}" fi - VERSIONS="$({ command awk -v lts="${LTS-}" '{ + VERSIONS="$( { command awk -v lts="${LTS-}" '{ if (!$1) { next } if (lts && $10 ~ /^\-?$/) { next } if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next } From f0f8ed12f8709aaf243649d93ab157a7f78205a8 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 25 Feb 2025 18:39:49 -0800 Subject: [PATCH 20/25] [Dev Deps] update `semver` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a616e40..c815359 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "eclint": "^2.8.1", "markdown-link-check": "^3.13.6", "replace": "^1.2.2", - "semver": "^7.6.3", + "semver": "^7.7.1", "urchin": "^0.0.5" } } From 5c12680a62cbe88b57cc243913373096b0f35647 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 11 Mar 2025 12:43:42 -0700 Subject: [PATCH 21/25] [Dev Deps] update `markdown-link-check` --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7806773..f4c61ad 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ - [Install & Update Script](#install--update-script) - [Additional Notes](#additional-notes) - [Installing in Docker](#installing-in-docker) + - [Installing in Docker for CICD-Jobs](#installing-in-docker-for-cicd-jobs) - [Troubleshooting on Linux](#troubleshooting-on-linux) - [Troubleshooting on macOS](#troubleshooting-on-macos) - [Ansible](#ansible) @@ -154,6 +155,62 @@ RUN echo node > .nvmrc RUN nvm install ``` +##### Installing in Docker for CICD-Jobs + +More robust, works in CI/CD-Jobs. Can be run in interactive and non-interactive containers. +See https://github.com/nvm-sh/nvm/issues/3531. + +```Dockerfile +FROM ubuntu:latest +ARG NODE_VERSION=20 + +# install curl +RUN apt update && apt install curl -y + +# install nvm +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + +# set env +ENV NVM_DIR=/root/.nvm + +# install node +RUN bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION" + +# set ENTRYPOINT for reloading nvm-environment +ENTRYPOINT ["bash", "-c", "source $NVM_DIR/nvm.sh && exec \"$@\"", "--"] + +# set cmd to bash +CMD ["/bin/bash"] + +``` + +This example defaults to installation of nodejs version 20.x.y. Optionally you can easily override the version with docker build args like: +``` +docker build -t nvmimage --build-arg NODE_VERSION=19 . +``` + +After creation of the image you can start container interactively and run commands, for example: +``` +docker run --rm -it nvmimage + +root@0a6b5a237c14:/# nvm -v +0.40.1 + +root@0a6b5a237c14:/# node -v +v19.9.0 + +root@0a6b5a237c14:/# npm -v +9.6.3 +``` + +Noninteractive example: +``` +user@host:/tmp/test $ docker run --rm -it nvmimage node -v +v19.9.0 +user@host:/tmp/test $ docker run --rm -it nvmimage npm -v +9.6.3 +``` + #### 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. diff --git a/package.json b/package.json index c815359..07b2625 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "dockerfile_lint": "^0.3.4", "doctoc": "^2.2.1", "eclint": "^2.8.1", - "markdown-link-check": "^3.13.6", + "markdown-link-check": "^3.13.7", "replace": "^1.2.2", "semver": "^7.7.1", "urchin": "^0.0.5" From 8dbc22f0e98b0f222d03dbf6a38b79848836d079 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 11 Mar 2025 12:46:19 -0700 Subject: [PATCH 22/25] [readme] update link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f4c61ad..4184b13 100644 --- a/README.md +++ b/README.md @@ -890,7 +890,7 @@ my_alias default v10.22.0 v12.18.3 v14.8.0 ## Compatibility Issues -`nvm` will encounter some issues if you have some non-default settings set. (see [#606](https://github.com/creationix/nvm/issues/606)) +`nvm` will encounter some issues if you have some non-default settings set. (see [#606](https://github.com/nvm-sh/nvm/issues/606)) The following are known to cause issues: Inside `~/.npmrc`: From df9ac58f8b73f7cdddad67396f1992acb0706b02 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 11 Mar 2025 13:16:58 -0700 Subject: [PATCH 23/25] [Fix] `reinstall-packages`: do not reinstall corepack Fixes #3544 --- nvm.sh | 2 +- .../should work as expected | 2 +- .../nvm reinstall-packages/works with no installs | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/nvm.sh b/nvm.sh index 736fb8e..6540356 100755 --- a/nvm.sh +++ b/nvm.sh @@ -2740,7 +2740,7 @@ nvm_npm_global_modules() { NPMLIST=$(nvm use "${VERSION}" >/dev/null && npm list -g --depth=0 2>/dev/null | command sed -e '1d' -e '/UNMET PEER DEPENDENCY/d') local INSTALLS - INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' | command xargs) + INSTALLS=$(nvm_echo "${NPMLIST}" | command sed -e '/ -> / d' -e '/\(empty\)/ d' -e 's/^.* \(.*@[^ ]*\).*/\1/' -e '/^npm@[^ ]*.*$/ d' -e '/^corepack@[^ ]*.*$/ d' | command xargs) local LINKS LINKS="$(nvm_echo "${NPMLIST}" | command sed -n 's/.* -> \(.*\)/\1/ p')" diff --git a/test/slow/nvm reinstall-packages/should work as expected b/test/slow/nvm reinstall-packages/should work as expected index 755c6f6..b705188 100755 --- a/test/slow/nvm reinstall-packages/should work as expected +++ b/test/slow/nvm reinstall-packages/should work as expected @@ -16,7 +16,7 @@ EXPECTED_PACKAGES_INSTALL="autoprefixer bower david@11 grunt-cli grunth-cli http echo "$EXPECTED_PACKAGES_INSTALL" | sed -e 's/test-npmlink //' | xargs npm install -g --quiet get_packages() { - npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs + npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' -e '/^corepack$/ d' | xargs } nvm use 0.10.29 diff --git a/test/slow/nvm reinstall-packages/works with no installs b/test/slow/nvm reinstall-packages/works with no installs index ade209a..ccd4632 100755 --- a/test/slow/nvm reinstall-packages/works with no installs +++ b/test/slow/nvm reinstall-packages/works with no installs @@ -5,7 +5,7 @@ die () { echo "$@" ; exit 1; } \. ../../../nvm.sh get_packages() { - npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' | xargs + npm list -g --depth=0 | \sed -e '1 d' -e 's/^.* \(.*\)@.*/\1/' -e '/^npm$/ d' -e '/^corepack$/ d' | xargs } nvm use 4.7.2 @@ -14,5 +14,14 @@ ORIGINAL_PACKAGES=$(get_packages) nvm reinstall-packages 4.7.1 FINAL_PACKAGES=$(get_packages) -[ -z "${ORIGINAL_PACKAGES}" ] || die "original packages were not empty: ${ORIGINAL_PACKAGES}" -[ -z "${FINAL_PACKAGES}" ] || die "final packages were not empty: ${FINAL_PACKAGES}" +[ -z "${ORIGINAL_PACKAGES}" ] || die "v4: original packages were not empty: ${ORIGINAL_PACKAGES}" +[ -z "${FINAL_PACKAGES}" ] || die "v4: final packages were not empty: ${FINAL_PACKAGES}" + +nvm use 23.8.20 +ORIGINAL_PACKAGES=$(get_packages) + +nvm reinstall-packages 23.8.0 +FINAL_PACKAGES=$(get_packages) + +[ -z "${ORIGINAL_PACKAGES}" ] || die "v23: original packages were not empty: ${ORIGINAL_PACKAGES}" +[ -z "${FINAL_PACKAGES}" ] || die "v23: final packages were not empty: ${FINAL_PACKAGES}" From ffec9fec724da725013d5b50e763908113983fc3 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 11 Mar 2025 13:30:37 -0700 Subject: [PATCH 24/25] v0.40.2 New Stuff - `install.sh`: add `$ZDOTDIR` to zsh search (#3458) Fixes - `reinstall-packages`: do not reinstall corepack (#3544) - avoid bash-specific syntax (#3499) - `install-latest-npm`: npm v11 is out - `nvm_install_latest_npm`: avoid unbound variable (#3447) - give a more helpful message when `lts` alias is mistakenly used (#3441) - `nvm ls`, `nvm alias`, `nvm install`: error when an LTS name is invalid - `nvm_normalize_lts`: error when an LTS name is not lowercase (#3417) Documentation - [readme] update link - [readme] fix `--no-use` example (#3479) - [readme] update copyright notice (#3507) - [readme] note zsh-nvm's AUTO_USE option (#2670) - [readme] add note about reloading zshrc after editing (#3052) - [readme] Update shell profile file install notes (#2241) - [readme] add docker tips (#2318) - [readme] remove `avn` from readme (#3469) - [readme] fnm -> nvm.fish (#2541) Refactors - prefer `case` over if/else chains - combine `sed -e` invocations/arguments Tests - `nvm exec`/`nvm run`: add `--silent` tests (#1259) - [actions] release test needs git tags - migrate `installation_iojs` test suite to GitHub Actions (#3476) - Migrate slow test suite from Travis CI (#3470) - temporarily skip this failing travis test to unblock progress - [actions] TOC: use latest LTS node - `install.sh`: clean up `nvm_detect_profile` tests - `nvm_detect_profile`: refactor (#3467) - run urchin tests on pull requests (#3466) - update mocks - ensure that unit tests use only mocked LTS names - [actions] use `node/install` instead of `node/run` Meta - disable blank issues - update issue template - add DCO (#3456) - Rename .github/ISSUE_TEMPLATE.md to .github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md (#3454) --- README.md | 30 +++++++++++++++--------------- install.sh | 2 +- nvm.sh | 2 +- package.json | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4184b13..7049f6e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ -# 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.40.1-yellow.svg)][4] [![CII Best Practices](https://bestpractices.dev/projects/684/badge)](https://bestpractices.dev/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.40.2-yellow.svg)][4] [![CII Best Practices](https://bestpractices.dev/projects/684/badge)](https://bestpractices.dev/projects/684) @@ -104,10 +104,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: ```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.2/install.sh | bash ``` ```sh -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.2/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 (`~/.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 file’s path, and then rerun the installation script. @@ -134,7 +134,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. -- 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.2/install.sh | bash'` #### Installing in Docker @@ -168,7 +168,7 @@ ARG NODE_VERSION=20 RUN apt update && apt install curl -y # install nvm -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash # set env ENV NVM_DIR=/root/.nvm @@ -194,7 +194,7 @@ After creation of the image you can start container interactively and run comman docker run --rm -it nvmimage root@0a6b5a237c14:/# nvm -v -0.40.1 +0.40.2 root@0a6b5a237c14:/# node -v v19.9.0 @@ -257,7 +257,7 @@ You can use a task: ```yaml - name: Install nvm ansible.builtin.shell: > - 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.2/install.sh | bash args: creates: "{{ ansible_env.HOME }}/.nvm/nvm.sh" ``` @@ -319,7 +319,7 @@ If you have `git` installed (requires git v1.7.10+): 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` -1. `cd ~/.nvm` and check out the latest version with `git checkout v0.40.1` +1. `cd ~/.nvm` and check out the latest version with `git checkout v0.40.2` 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: @@ -925,13 +925,13 @@ If installing nvm on Alpine Linux *is* still what you want or need to do, you sh ### Alpine Linux 3.13+ ```sh 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.40.1/install.sh | bash +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash ``` ### Alpine Linux 3.5 - 3.12 ```sh 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.40.1/install.sh | bash +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/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._ @@ -1034,9 +1034,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) [1]: https://github.com/nvm-sh/nvm.git -[2]: https://github.com/nvm-sh/nvm/blob/v0.40.1/install.sh +[2]: https://github.com/nvm-sh/nvm/blob/v0.40.2/install.sh [3]: https://app.travis-ci.com/nvm-sh/nvm -[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.40.1 +[4]: https://github.com/nvm-sh/nvm/releases/tag/v0.40.2 [Urchin]: https://git.sdf.org/tlevine/urchin [Fish]: https://fishshell.com @@ -1094,7 +1094,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. 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. - 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.40.176) + 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.40.276) - Exit back to your native shell. @@ -1121,7 +1121,7 @@ Now you should be able to use node as usual. If you've encountered this error on WSL-2: ```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.2/install.sh | bash % Total % Received % Xferd Average Speed Time Time Time Current 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 @@ -1156,7 +1156,7 @@ Currently, the sole maintainer is [@ljharb](https://github.com/ljharb) - more ma ## Project Support -Only the latest version (v0.40.1 at this time) is supported. +Only the latest version (v0.40.2 at this time) is supported. ## Enterprise Support diff --git a/install.sh b/install.sh index f8bafd4..79ae3b1 100755 --- a/install.sh +++ b/install.sh @@ -33,7 +33,7 @@ nvm_install_dir() { } nvm_latest_version() { - nvm_echo "v0.40.1" + nvm_echo "v0.40.2" } nvm_profile_is_bash_or_zsh() { diff --git a/nvm.sh b/nvm.sh index 6540356..01820fc 100755 --- a/nvm.sh +++ b/nvm.sh @@ -4438,7 +4438,7 @@ nvm() { NVM_VERSION_ONLY=true NVM_LTS="${NVM_LTS-}" nvm_remote_version "${PATTERN:-node}" ;; "--version" | "-v") - nvm_echo '0.40.1' + nvm_echo '0.40.2' ;; "unload") nvm deactivate >/dev/null 2>&1 diff --git a/package.json b/package.json index 07b2625..2ae3850 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nvm", - "version": "0.40.1", + "version": "0.40.2", "description": "Node Version Manager - Simple bash script to manage multiple active node.js versions", "directories": { "test": "test" From 424c4a702db0e7b5e0c097f76e169ffa8c8c7fd0 Mon Sep 17 00:00:00 2001 From: Nodoubtz <53144580+nodoubtz@users.noreply.github.com> Date: Thu, 13 Mar 2025 10:12:07 -0400 Subject: [PATCH 25/25] Create npm-publish.yml --- .github/workflows/npm-publish.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..2a4766d --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,33 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: npm ci + - run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}}