
Photo by Bill Jelen | Unsplash
Installing fnm on Windows for PowerShell, Git Bash, and Command Prompt
fnm (Fast Node Manager) lets you easily manage multiple Node.js versions. While installation is simple, configuring it across different Windows shell requires additional setup.
You can install fnm from either winget or chocolatey:
winget install Schniz.fnm
# or
choco install fnm
From there, we need to install the specific version of Node you want to use. Iβm going to use 22 as an example.
fnm install 22
Now, if you open a new shell and run node --version, you'll get the error, "The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program."

This happens because fnm needs to modify your PATH dynamically when switching Node versions. Setting a static PATH in the Windows environment variables isn't enough.
The solution is to run fnm env --use-on-cd at the start of each shell session.
PowerShell
Open PowerShell as an administrator. To do this, you can right-click the Start button and select "Windows PowerShell (Admin)".
First, enable script execution if you haven't already.
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Create or modify your PowerShell profile:
notepad $PROFILE
If your PowerShell profile already exists, that should open it. If not, it will create a new profile file for you, in which case it will be blank.
Add this line to the end of your profile.
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
Save and close the file. The profile is reloaded automatically each time you start a new PowerShell session, so you need to close and open PowerShell again for it to take effect.
You can verify that it worked by running node --version. The current version, in my case "v22.13.1", should be displayed.
Git Bash
The following configuration needs to be done in Git Bash, so start a new Git Bash session.
Create or modify your .bashrc. The reason why weβre running touch first is because if the file does not exist, Notepad will automatically create it as .bashrc.txt, which is not what we want. If ~/.bashrc already exists, touch will do nothing.
touch ~/.bashrc
notepad ~/.bashrc
Add this line to the end of your ./bashrc file:
eval "$(fnm env --use-on-cd --shell bash)"
Same as PowerShell, you'll need to close and open Git Bash for the changes to take effect. Start a new Git Bash session and verify with node --version.
Command Prompt
Command Prompt doesn't have profile scripts like other shells. Instead, we can use the registry to recreate a similar kind of behavior.
Despite the fact that we're configuring Command Prompt, we'll be using PowerShell to set it up, so start a new PowerShell session.
First, create a profile.cmd in your user directory. In the following script, be sure to replace "XXX" with your Windows username.
$profileContent = @"
@echo off
if not defined FNM_AUTORUN_GUARD (
set "FNM_AUTORUN_GUARD=AutorunGuard"
FOR /f "tokens=*" %%z IN ('fnm env --use-on-cd') DO CALL %%z
)
"@
Set-Content -Path "C:\Users\XXX\profile.cmd" -Value $profileContent
Then, run the following command to set the AutoRun registry key. Again, be sure to replace "XXX" with your Windows username.
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Command Processor" -Name "AutoRun" -Value "C:\Users\XXX\profile.cmd"
Start a new Command Prompt and verify with node --version.
A global fallback for apps not launched from a shell
The configurations above only apply to processes that start a shell. Apps launched from Explorer (the Start menu, a desktop icon, a taskbar item β for example VS Code opened from Explorer rather than code .) don't run these profiles, so they never get the PATH that fnm sets up.
The fix is to put fnm's default version on the global PATH. fnm keeps a stable symlink at %APPDATA%\fnm\aliases\default that always points at your default version, so it's safe to add permanently β fnm just repoints the link when you change the default. Shells still override it with the per-directory version via --use-on-cd, so this is purely a fallback.
First, set a default version (using 22 from before):
fnm default 22
Confirm node.exe is present under the alias. If you've changed FNM_DIR, run fnm env and use that path instead:
Get-ChildItem "$env:APPDATA\fnm\aliases\default" -Filter node.exe
Add that directory to your user PATH. Run this once β running it again would append a duplicate:
[Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path","User") + ";$env:APPDATA\fnm\aliases\default", "User")
Finally, sign out and back in so Explorer picks up the new PATH.