nvm use
Packages and runtimes
Usage
nvm use <version> | nvm use --ltsSwitches which installed Node the current shell uses; the change lives in that shell only, so a new terminal or a CI job falls back to the default, and because nvm is a shell function a script or Makefile has to source nvm.sh first.
Common flags
| Flag | Meaning |
|---|---|
| --lts | the newest long-term-support line you have installed |
| nvm install <version> | download it first; use only switches to installed ones |
| nvm alias default <version> | what a brand-new shell should start with |
| nvm ls | the versions on this machine |
| nvm current | which one is active in this shell |
Examples
nvm use 22switches this shell to node 22
nvm use --ltsswitches to the newest installed LTS
nvm alias default 22so new terminals and editors also get 22
The question is always what goes where: inside this project, or on the whole machine.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does nvm use do?
Switches which installed Node the current shell uses; the change lives in that shell only, so a new terminal or a CI job falls back to the default, and because nvm is a shell function a script or Makefile has to source nvm.sh first.
Q. How do I type it?
nvm use <version> | nvm use --lts — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man nvm. This command sits under Packages and runtimes.
Related commands
man page: man nvm-use