Using Fast Node Manager in Windows
When I visited the official Node.js download page after a long time, I noticed fnm (Fast Node Manager) listed as the default download option. I've been successfully using NVM for Windows as the version manager for quite some time, but it wasn't a perfect solution, so I decided to give fnm a try.
To avoid any potential conflicts between the two tools, I decided to uninstall NVM for Windows before installing fnm. Although the uninstaller promises to remove all installed versions of Node, I decided to do it by hand before running the uninstaller, as an extra precaution. The process was simple enough:
- List all installed versions of Node:
nvm list
- Uninstall each of the versions listed, for example:
nvm uninstall 20.8.1
Since NVM for Windows must be run with admin privileges, I had a couple of functions in my PowerShell profile to temporarily elevate the privileges when switching the Node version from a non-privileged terminal. I removed those as well by:
- editing the profile in Visual Studio Code:
code $PROFILE
- and reloading the profile in the existing terminal after saving the changes:
. $PROFILE
Now I was ready to set up fnm. The process is well documented, using several package managers. I'm still a Chocolatey user, so that's what I used:
choco install fnm
The next step was registering environment variables with PowerShell by adding the following line to my PowerShell profile, using the same process as before for removing my NVM functions:
fnm env --use-on-cd --version-file-strategy=recursive --shell powershell | Out-String | Invoke-Expression
The arguments are used to configure the behavior of fnm. I chose:
--use-on-cd
to automatically switch to the correct Node version when navigating to a folder with a.npmrc
file, and--version-file-strategy=recursive
to read the.npmrc
file from a parent folder when it isn't present in the current folder.
To get up and running, I had to install the Node versions, I still work with:
fnm install 20 # install Node 20
fnm install 22 # install Node 22
fnm default 22 # set Node 22 as the default Node version
fnm use default # switch to default Node version (22)
That was enough to do everything I used to do with NVM for Windows, but better:
fnm use 20
would manually change the Node version in current terminal only and without needing admin privileges.fnm use
would change the Node version according to.npmrc
, but thanks to the--use-on-cd
configuration argument I don't even have to call it as it happens automatically when navigating to a folder. That motivated me to add the.nvmrc
file to a couple of projects still without it by callingnode -v > .nvmrc
after manually switching to the correct Node version for the project.
I haven't used fnm for long, but based on the experience so far, I like it better than NVM for Windows. It solves a couple of inconveniences in NVM for Windows, and offers an even better experience than nvm on Linux or macOS. I'm happy to have learned about it when I randomly visited the Node.js download page.