How to work with multiple NodeJS versions using fnm?

Working with multiple NodeJS projects can be challenging at times with different NodeJS version requirements. There are multiple tools that can help with working with multiple versions like

  • nvm
  • n
  • fnm (My go-to approach which is performance and version oriented, for non docker projects)
  • Docker (Always suggest going for docker setup, read the article below for more)
Why should you learn docker?
Gone are those days when you could be an expert of a certain language/framework and survive as a developer in the Industry. In today’s fast-moving tech world, you are expected to be a problem solver. Companies want people who can understand the business problem and build a solution to

fnm

After working with multiple node version managers, my personal favorite, recently has become, fnmdue to its performance and simplicity.

Installing fnm

mac users using homebrew

brew install fnm

Using fnm

  • fnm list - shows all the node versions installed in the system
  • fnm list-remote - Shows all the available node versions which can be installed.
  • fnm install <version> - Install the node version locally which we got from list command. eg- fnm install v14.0.2  would install v14.0.2 locally.
  • fnm use <version> - Activate the given version which is installed in the system. eg - fnm use v16.13.2 would activate v16.13.2 which is installed
  • fnm default <version> - Set the node version to default alias. eg fnm default v16.13.2 would make  v16.13.2 as the default version for the system.
  • fnm current - Prints the current node version which is activated.

For more details on the available command, please check the below documentation

fnm/commands.md at master · Schniz/fnm
🚀 Fast and simple Node.js version manager, built in Rust - fnm/commands.md at master · Schniz/fnm