nvm install: Usage, Options & Common CI Errors
nvm install downloads a specific Node.js version into your per-user nvm directory.
nvm manages multiple Node.js versions per user. Its defining CI gotcha is that nvm is a shell function, not a binary - non-interactive CI shells do not source it, so "nvm: command not found" is the number-one failure.
What it does
nvm install <version> downloads and installs a Node.js version under ~/.nvm and (without --no-use) switches to it. It reads .nvmrc for a project-pinned version. Because nvm is defined by sourcing nvm.sh in your shell profile, a fresh non-login CI shell will not have it unless you source it explicitly.
Common usage
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # MUST source it first
nvm install 20
nvm install --lts
nvm install # install version from .nvmrc
nvm use 20Common errors in CI
"nvm: command not found" is the classic: CI runs a non-interactive shell that never sources ~/.bashrc, so nvm is undefined - source $NVM_DIR/nvm.sh at the top of the step (and note each step is a fresh shell, so re-source per step or per job). "Version X not found" / "N/A: version not yet installed" means you used a version you never installed, or the alias (lts/*) needs nvm install --lts. nvm install but then a separate step's node is the system node? You did not re-source / nvm use in that step.
Options
| Flag | What it does |
|---|---|
| --lts | Install the latest LTS release |
| --no-use | Install without switching the active version |
| (no arg) | Install the version named in .nvmrc |
| --latest-npm | Upgrade npm after installing Node |