Herold
Solutions
Blog
Preview for Windows and the Node Version Manager

Windows and the Node Version Manager

Manage multiple NodeJS versions for different project needs on the system

February 27, 20236 min read

Imagine you are a NodeJS developer but you work at multiple projects. One is on the latest LTS version in one you are testing the newest features of the latest nightly build and one is just an old legacy projects on Node 14 or something older where you want to fix some simple bugs. You want to switch between those projects multiple times a day but you can't use one Node Version for every project. But what is here the solution? Install every time you switch the project a new (or old) Node version? No! Here is the time where a node manager can shine.

The described scenario is exactly what I have with my setup and now I have a for me working solution. There are multiple node manager solutions out there. One of the biggest in my mind is nvm but there are some more. I had the chance to test the most of them and make a decision which one fits my needs the best.

Version management options

n - Node version management

n is a simple and easy to use node version manager. It can be installed by npm i -g n but my big problem with n is the platform support. This only supports Linux, MacOS and the Windows Subsystem for Linux but not the nativ Windows shell or the Git Bash. As a Windows user I need to use it outside of the subsystem so no hard decision for not using this.

nvm - Node Version Manager

I think nvm is the most known node version manager. It has a nice auto switch mode if you have a .nvmrc file in your project and navigate to the project directory your shell will automatically switch the node version to the needed one. But here comes the same downer as with n, nvm doesn't support the windows cmd but it does support the git bash. The bad thing is that not every script I use is written as bash script.

nvm-windows - A node.js version management utility for Windows

But there are adaption like nvm-windows. It implements the same functionally as nvm but with full windows support. Sounds nice? Yea it is, as long as you got admin right or developer mode on you computer. But as my company computer has some limitations so that I can't activate the developer mode it is not very friendly to enter every few minutes your admin access to change the node version. But as long as you got full admin rights this could be a solution.

volta - The Hassle-Free JavaScript Tool Manager

Another solution I tried is volta. hassle-free sounds good and sounds like something I want. Installation was as easy as nvm-windows. But after this the same Problem as in nvm-windows appears. It needs the same admin access rights at some points as nvm. So I also uninstall volta because of this big problem on my company computer.

fnm - Fast Node Manager

I was near a point to give up and just use the subsystem to use node. But then I found fnm. This node manager is just what I want and need. The setup need a bit more effort but if everything is configured correctly it didn't need admin access rights and has also a nvm support. So just like nvm you can create a .nvmrc or a .node-version file in you project folder and the shell will automatically switch the node version as needed. And if there is a version that you don't have installed it will ask you if you want to install this new (or old) version.

The extra effort that is needed is that not every shell is configured automatically. You have to add the needed configuration for each shell you want to use. So for me it's the git bash, windows cmd, subsystem for linux and the husky shell. But after the completed setup this works like a charm for me. I can navigate to the project, auto change to the needed node version and can start my work.

A extra plus for fnm is that this works on every platform. It works on Linux, MacOS and Windows so if I ever choose to change my setup I can use the same commands as a already use.

Conclusion

As a final word I think we can say that there are many solutions for node version management but you have to find one that works with your personal setup and is for you personally easy to use. If you want I can write a extra blog entry about how to setup fnm like I did it. I simplified it with some script to initialize the setup for the different shells so that I just have to execute those instead of look the configuration up every time. If you want those you can contact me at Twitter and I will create another blog entry to share and explain what is needed and how we can automatic set the configuration.

Selfie of Felix Herold

The article was helpful, or are you feeling a bit unsure about anything?