mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-08-17 19:13:43 +00:00
Compare commits
1 Commits
cd7319b833
...
54310eb1f2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
54310eb1f2 |
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -31,8 +31,6 @@ jobs:
|
||||
suite:
|
||||
- install_script
|
||||
- sourcing
|
||||
- slow
|
||||
- installation_iojs
|
||||
shell:
|
||||
- sh
|
||||
- bash
|
||||
|
10
.travis.yml
10
.travis.yml
@ -87,8 +87,18 @@ 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
|
||||
- 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
|
||||
|
18
Dockerfile
18
Dockerfile
@ -91,20 +91,16 @@ 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"' >> "$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"
|
||||
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"
|
||||
|
||||
# nodejs and tools
|
||||
RUN nvm install node
|
||||
RUN npm install -g doctoc urchin eclint dockerfile_lint
|
||||
RUN npm install --prefix "$HOME/.nvm/"
|
||||
RUN bash -c 'source $HOME/.nvm/nvm.sh && \
|
||||
nvm install node && \
|
||||
npm install -g doctoc urchin eclint dockerfile_lint && \
|
||||
npm install --prefix "$HOME/.nvm/"'
|
||||
|
||||
# Set WORKDIR to nvm directory
|
||||
WORKDIR /home/nvm/.nvm
|
||||
|
44
README.md
44
README.md
@ -18,7 +18,6 @@
|
||||
- [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)
|
||||
@ -109,7 +108,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 (`~/.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.
|
||||
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`).
|
||||
|
||||
<a id="profile_snippet"></a>
|
||||
```sh
|
||||
@ -121,12 +120,7 @@ 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>
|
||||
|
||||
- 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 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 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.
|
||||
@ -135,25 +129,6 @@ 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.
|
||||
@ -232,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
|
||||
- [nvm.fish](https://github.com/jorgebucaran/nvm.fish) - The Node.js version manager you'll adore, crafted just for Fish
|
||||
- [fnm](https://github.com/fisherman/fnm) - [fisherman](https://github.com/fisherman/fisherman)-based version manager 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:
|
||||
@ -252,7 +227,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 ([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:** 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:** 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.
|
||||
|
||||
@ -613,7 +588,9 @@ Run [`npx nvmrc`](https://npmjs.com/nvmrc) to validate an `.nvmrc` file. If that
|
||||
|
||||
### 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.
|
||||
|
||||
@ -708,8 +685,6 @@ 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.
|
||||
@ -1113,5 +1088,6 @@ 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/). 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/)
|
||||
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/)
|
||||
|
Loading…
x
Reference in New Issue
Block a user