fnm is installed but node does not work in a new terminal
node: command not foundShort answer
fnm only changes your PATH when your shell runs fnm env at startup. Add the setup line for your shell (PowerShell, cmd, bash or zsh), open a new terminal, then install a version and set it as default so every new terminal gets it. A missing PATH entry for fnm itself is the other cause.
Fix it fast
1Find out which cause you have
Check that fnm itself runs, then list the versions it has installed.
fnm --version fnm list2Match what you see, then jump to its fix
- 1
fnm --version works, fnm list shows a version, but node is not found in a new terminalThe shell never runs fnm envFix - 2
On Windows, you cannot find the file to put the line in, or the setup line has no effectThe PowerShell profile file does not exist yetFix - 3
node works after fnm use in one terminal but is missing in the next oneNo version is set as the defaultFix - 4
Can't find version in dotfiles. Please provide a version manually to the command.fnm use is run in a folder with no version fileFix
- 1
What does the error look like?
node: command not found'node' is not recognized as an internal or external commandCan't find version in dotfiles. Please provide a version manually to the command.
Cause 1 of 4
The shell never runs fnm env
1Check
fnm sets up node by printing shell commands that your shell must evaluate at startup. Look for the line in your profile.
# bash / zsh
grep -n "fnm env" ~/.bashrc ~/.zshrc
# PowerShell
Select-String "fnm env" $profile2Fix
Add the line for your shell. With --use-on-cd you only need to cd into a folder to switch versions. The README recommends passing --shell explicitly.
# ~/.bashrc
eval "$(fnm env --use-on-cd --shell bash)"
# ~/.zshrc
eval "$(fnm env --use-on-cd --shell zsh)"
# PowerShell profile
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression3Verify
Open a new terminal window (or reload the profile) and ask for the version.
node -vConfirmed by github.com
Cause 2 of 4
The PowerShell profile file does not exist yet
1Check
A PowerShell profile is a file that may not exist. Its path differs between Windows PowerShell 5 and PowerShell 6+.
$profile
Test-Path $profile2Fix
Create the profile if it is missing, open it and add the fnm line at the end.
if (-not (Test-Path $profile)) { New-Item $profile -Force }
Invoke-Item $profile3Verify
Start a new PowerShell window and run node -v.
node -vConfirmed by github.com
Cause 3 of 4
No version is set as the default
1Check
fnm use only changes the current terminal. A default version is what every new shell starts with.
fnm list2Fix
Install a version and set it as default. fnm default is shorthand for fnm alias VERSION default.
fnm install 22
fnm default 223Verify
Open a new terminal and check the version.
node -vConfirmed by github.com
Cause 4 of 4
fnm use is run in a folder with no version file
1Check
fnm use with no argument looks for a version in dotfiles of the project.
ls -a2Fix
Pass the version, or add a version file to the project. The --install-if-missing option installs it when absent.
fnm use --install-if-missing 223Verify
Confirm the active version.
node -vConfirmed by github.com
How do I stop it coming back?
- Put the fnm setup line in your dotfiles repo so a new machine gets it with the rest.
- Always set a default version right after installing fnm.
- Commit a Node.js version file in each project so fnm use needs no argument.
- On Windows, prefer PowerShell: the fnm README says cmd support is not entirely covered.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
The nest command is not found in the terminal
bash: nest: command not found
The shell cannot find a nest executable on its PATH.
3 causes, each with a fixBack end
npm install worked but the command is not found
bash: vite: command not found
npm puts a local install's command in the project's node_modules/.bin, which is not on your shell PATH, so run it with npx or from an npm script.
3 causes, each with a fixBack end
node and npm vanish or are not found when nvm is installed
nvm current prints system in a new shell
nvm adds node and npm to PATH only for the version it has activated.
4 causes, each with a fixBack end
The serverless command is not found in the shell
bash: serverless: command not found
The shell can only run serverless if it is installed globally and the folder npm links global commands into is on PATH.
3 causes, each with a fixBack end
npm or a script fails in WSL with /usr/bin/env: 'bash\r'
/usr/bin/env: 'bash\r': No such file or directory
The \r in the message is a Windows line ending at the end of a script's first line, so Linux looks for a program called bash followed by a carriage return.
2 causes, each with a fixBack end
yarn command not found, or yarn global binaries not found
zsh: command not found: yarn
The shell cannot find the yarn binary or a tool installed with yarn global.
4 causes, each with a fix