nvm Shell Setup
Configure shell profiles so nvm loads automatically on every new terminal session.
Workflow
-
Identify the shell and profile file:
- bash:
~/.bashrc(or~/.bash_profileon macOS) - zsh:
~/.zshrc - fish:
~/.config/fish/config.fish - With XDG_CONFIG_HOME:
$XDG_CONFIG_HOME/bash/bashrcetc.
- bash:
-
Add nvm initialization to the correct profile:
# Required lines for bash/zsh: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" -
Optional: Load nvm without switching versions (faster shell startup):
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use -
Verify nvm loads in a new shell:
# Open a new terminal, then: command -v nvm # Should print "nvm" nvm --version # Should print version number
Notes:
- XDG_CONFIG_HOME changes the expected profile path.
- Use
--no-usewhen you only want nvm loaded without switching versions. - For installation, use the nvm-install skill. For version usage, use nvm-usage-basics.
Example file map
templates/shell-config.md- Profile configuration templatesexamples/environment-variables.md- Environment variable referenceexamples/bash-completion.md- Bash completion setupexamples/bash-completion-usage.md- Completion usage examples
Keywords
nvm setup, NVM_DIR, nvm.sh, profile, bash, zsh, fish, XDG_CONFIG_HOME, shell init