Managing Node.js versions on Windows with fnm (Fast Node Manager) requires both an executable available on your PATH and shell initialization. This guide covers installation, missing commands in Git Bash, and loading the same setup in VS Code.
Setting up fnm with Git Bash on Windows
Introduction
Start by installing fnm in PowerShell, then configure Git Bash to initialize its environment. If a command is missing, check its PATH before changing your shell startup files.
Prerequisites
Before diving in, make sure you have:
- Windows 10 or 11 with an up-to-date installation
- Git for Windows (Git Bash) installed
- Windows Package Manager (winget) available
1. Installing fnm via winget
The simplest way to install fnm on Windows is through the Windows Package Manager:
winget install Schniz.fnm
After installation, restart Git Bash and check fnm --version. If Git Bash cannot find fnm, check where.exe fnm in PowerShell and make sure the executable’s directory is available on your Git Bash PATH. You do not need winget to be available in Bash if you install fnm from PowerShell.
1.1 Fixing “bash: winget: command not found”
If you also want to run winget from Git Bash and the command is missing, check whether WindowsApps is on your PATH.
Check winget in PowerShell
In PowerShell, run:
Get-Command winget.exe | Select-Object -ExpandProperty Source
This shows the executable PowerShell resolves. If winget is unavailable there too, check your Windows Package Manager installation before editing Bash configuration.
Add it to your Git Bash PATH
Open (or create) your ~/.bashrc and add:
# Winget in Git Bash
export PATH="$PATH:/c/Users/YourUserName/AppData/Local/Microsoft/WindowsApps"
Replace YourUserName with your Windows username and confirm the directory exists. Then reload:
source ~/.bashrc
Check winget --version before running installation commands from Git Bash.
2. Verifying fnm and Handling the “node: command not found” Error
Even after installing a Node.js version with fnm, you may still see:
$ node -v
bash: node: command not found
If fnm --version works but node is missing, check whether your shell initializes fnm and selects an installed Node.js version.
2.1 Adding the fnm environment hook
In ~/.bashrc, add the following snippet near the bottom:
eval "$(fnm env --use-on-cd --shell bash)"
This follows the official fnm Bash setup. It initializes the Node.js environment and enables version switching when you change directories into projects with .node-version or .nvmrc files. The fnm executable must already be on your PATH; do not assume a Windows installation lives in ~/.fnm/bin.
Reload your shell:
source ~/.bashrc
fnm install --lts
fnm use --lts
node -v
npm -v
If verification fails, inspect command -v fnm and fnm list to distinguish an executable PATH problem from a missing Node.js version.
3. Making fnm and Node Available in VS Code’s Integrated Terminal
If the setup works in standalone Git Bash but not in VS Code, restart VS Code so it inherits PATH changes, then check its terminal profile and shell startup files.
3.1 Launching Bash as Login & Interactive
- Open Settings (Ctrl + ,)
- Search for terminal.integrated.profiles.windows
- Edit (or add) the Git Bash profile:
"terminal.integrated.profiles.windows": {
"Git Bash": {
"path": "C:\\Program Files\\Git\\bin\\bash.exe",
"args": ["-l", "-i"] // Login & interactive
}
},
"terminal.integrated.defaultProfile.windows": "Git Bash"
The -l flag loads login startup files, while -i enables an interactive shell. Interactive login shells read the first available file among ~/.bash_profile, ~/.bash_login, and ~/.profile; that file should source ~/.bashrc. If it does not already do so, add:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
Restart VS Code’s terminal.
3.2 Verifying in VS Code
Open a new terminal in VS Code and run:
node -v && npm -v && fnm --version
You should see the versions of Node, npm, and fnm printed without errors. If not, double-check that your ~/.bashrc includes the fnm hook and that VS Code is indeed using the “Git Bash” profile with the -l -i args.
Conclusion
By explicitly adding WindowsApps to Git Bash’s PATH, initializing fnm in your shell startup file, and configuring VS Code to launch Bash as a login and interactive shell, you can seamlessly install and manage multiple Node.js versions on your Windows machine using fnm. Happy coding!