mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-26 04:10:36 +08:00 
			
		
		
		
	[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>
This commit is contained in:
		
				
					committed by
					
						 Jordan Harband
						Jordan Harband
					
				
			
			
				
	
			
			
			
						parent
						
							287d535f2c
						
					
				
				
					commit
					b77fcec399
				
			
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								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. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user