mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-12-12 16:14:18 +00:00
Compare commits
6 Commits
fix-3474
...
d4cc592ff1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4cc592ff1 | ||
|
|
c8b55175dc | ||
|
|
db0b085965 | ||
|
|
206302caad | ||
|
|
42a5175402 | ||
|
|
02795cd71d |
5
.github/workflows/latest-npm.yml
vendored
5
.github/workflows/latest-npm.yml
vendored
@@ -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"
|
||||||
|
|||||||
3
.github/workflows/toc.yml
vendored
3
.github/workflows/toc.yml
vendored
@@ -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
|
||||||
|
|||||||
@@ -588,7 +588,9 @@ Run [`npx nvmrc`](https://npmjs.com/nvmrc) to validate an `.nvmrc` file. If that
|
|||||||
|
|
||||||
### Deeper Shell Integration
|
### Deeper Shell Integration
|
||||||
|
|
||||||
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 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).
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
29
nvm.sh
29
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
|
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)"
|
||||||
@@ -1667,11 +1688,10 @@ EOF
|
|||||||
LTS="${LTS#lts/}"
|
LTS="${LTS#lts/}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSIONS="$({ command awk -v lts="${LTS-}" -v pattern="${PATTERN:-.*}" '{
|
VERSIONS="$({ command awk -v lts="${LTS-}" '{
|
||||||
if (!$1) { next }
|
if (!$1) { next }
|
||||||
if (lts && $10 ~ /^\-?$/) { next }
|
if (lts && $10 ~ /^\-?$/) { next }
|
||||||
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
if (lts && lts != "*" && tolower($10) !~ tolower(lts)) { next }
|
||||||
if ($1 !~ pattern) { next }
|
|
||||||
if ($10 !~ /^\-?$/) {
|
if ($10 !~ /^\-?$/) {
|
||||||
if ($10 && $10 != prev) {
|
if ($10 && $10 != prev) {
|
||||||
print $1, $10, "*"
|
print $1, $10, "*"
|
||||||
@@ -1683,6 +1703,7 @@ EOF
|
|||||||
}
|
}
|
||||||
prev=$10;
|
prev=$10;
|
||||||
}' \
|
}' \
|
||||||
|
| nvm_grep -w "${PATTERN:-.*}" \
|
||||||
| $SORT_COMMAND; } << EOF
|
| $SORT_COMMAND; } << EOF
|
||||||
$VERSION_LIST
|
$VERSION_LIST
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ die () { echo "$@" ; exit 1; }
|
|||||||
\. ../../../nvm.sh
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
# Version to install/uninstall
|
# Version to install/uninstall
|
||||||
NVM_TEST_VERSION=5.10.1
|
NVM_TEST_VERSION=15.5.0
|
||||||
|
|
||||||
# Make sure it's not already here
|
# Make sure it's not already here
|
||||||
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION
|
||||||
@@ -19,7 +19,9 @@ nvm ls | grep "$NVM_TEST_VERSION" || die "Failed to install node"
|
|||||||
|
|
||||||
# Install global module as root
|
# Install global module as root
|
||||||
npm_path=$(which npm)
|
npm_path=$(which npm)
|
||||||
sudo -n "$npm_path" install jspm@'<2' -g || die 'either sudo failed, or `npm install jspm -g` failed`'
|
nvm_err "${PATH}"
|
||||||
|
PATH="${PATH}" sudo -n echo "${PATH}" || die 'sudo echo failed'
|
||||||
|
PATH="${PATH}" sudo -n "$npm_path" install jspm@'<2' -g || die 'either sudo failed, or `npm install jspm -g` failed`'
|
||||||
|
|
||||||
# Switch to another version so we can uninstall
|
# Switch to another version so we can uninstall
|
||||||
nvm use 0.12.7
|
nvm use 0.12.7
|
||||||
|
|||||||
Reference in New Issue
Block a user