mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-17 09:31:51 +00:00
Compare commits
4 Commits
759f70f196
...
df9ac58f8b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
df9ac58f8b | ||
![]() |
8dbc22f0e9 | ||
![]() |
5c12680a62 | ||
![]() |
f0f8ed12f8 |
59
README.md
59
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.
|
||||
@ -833,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`:
|
||||
|
2
nvm.sh
2
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')"
|
||||
|
@ -45,9 +45,9 @@
|
||||
"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.6.3",
|
||||
"semver": "^7.7.1",
|
||||
"urchin": "^0.0.5"
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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}"
|
||||
|
Loading…
Reference in New Issue
Block a user