In the web development industry, Node.js is a household name. This is because it powers everything from video streaming on Netflix to helping astronauts stay safe in space.
When it comes to installing Node.js on a development machine, you would normally install the environment using these steps:
- First, navigate to the Node.js website and procure the latest LTS version:
- The installation process differs across different OSes. For example, if you’re on Windows or macOS, run the executable installer. Alternatively, if you’re on Linux, use NodeSource to install Node on your machine:
- As time goes on, you also have to manually check whether an update is available. If this is true, you would have to uninstall the previous version of Node and perform this process all over again.
You might think to yourself, “Sure, this process works for me.” However, there is a minor flaw in this process: it is too tedious and time-consuming. This is because of the following reasons:
- Node.js doesn’t notify users when an update is available, which means that the developer has to regularly check for updates
- Furthermore, every time an update is available, you have to reinstall Node all over again, which wastes time and energy
- Finally, you can’t install different versions of Node on one computer. This is problematic in situations where, for example, a certain project relies on Node v 16 and another app uses Node v 18
This is where
fnm comes in. It is a piece of software written in Rust that allows developers to switch between Node versions with relative ease.
In this article, you will learn about the
fnm project. Here is what we’ll cover:
- What is
fnm, and why you should use it?
- Managing Node.js versions with fnm
- Setting Node.js version aliases
- Alternatives to
What is fnm, and why you should use it?
fnm, or Fast Node Manager, is a Node version manager that was written in Rust. Since it is a version manager, it boasts the easy installation of different Node.js versions. You can install Node via the
Other than that, uninstalling is a breeze. For example, we can remove different Node versions using the
fnm uninstall <version> #uninstall a version of Node.js fnm uninstall 19.3.0 #use this version of Node.js
Moreover, this project is written in Rust. This means that
fnm brings speed and stability to the table.
fnm team bundles an installation script that makes downloading the software a breeze. To run this script, type this command in your terminal:
curl -fsSL https://fnm.vercel.app/install | bash
Don’t want to use the terminal? No problem! Head over to the Releases page and install their binaries.
When that’s done, verify that everything works by writing this bash command:
This should return this result:
This means that our installation was successful! In the next section, we will now learn how to install Node.js using
Managing Node.js versions with fnm
To download and install specific versions of Node.js, use the following syntax:
fnm install <version>
For example, this command installs
14.15.0 on the dev machine:
fnm install 14.15.0
Alternatively, if you want to use the latest version, simply use the
--latest flag, like so:
fnm install --latest
This will be the result:
Otherwise, to install the
lts version, just pass the
Listing all Node.js versions
This bash command tells
fnm to list all Node versions that are available to download:
If you want to see what versions are installed on the system, just write:
As you can see, in my case, two Node.js versions (
19) were installed on the local machine.
Using a particular version of Node.js
To use a specific version of Node, we have to run the
use command. It follows this syntax:
fnm use <version>
For example, if you want your computer to switch to Node
fnm use 19.3.0
We can verify that we’ve changed our version with the
This indicates that our machine is now running Node version
Uninstalling Node.js versions
To purge certain Node installations, use the
uninstall keyword like so:
fnm uninstall <version>
For example, this removes Node
fnm uninstall 19.3.0 #uninstall the latest version of node
Setting Node.js version aliases
Aliases allow developers to “name” certain Node versions semantically. This is a great feature because it means that programmers don’t need to remember multiple Node versions if they’re working on many projects.
To set an alias, use this syntax:
fnm alias <version> <name>
fnm alias 18.12.1 my-project
The above command assigns the
my-project alias to Node version
To verify whether our alias was successfully configured, we can re-run
In some cases, developers might encounter bugs, such as command issues during development. As a result, you may have to reinstall the
fnm tool to fix this. In this section, you will learn how to delete
fnm from your machine.
To purge fnm, we have to first find its installation directory:
fnm env #get all environment variables
FNM_DIR variable indicates the location of
fnm. As the next step, go to the path and simply remove the
fnm folder like so:
#in this case, fnm was in the 'share' folder cd $HOME/.local/share rm -rf fnm #removing this folder will uninstall this software
And we’re done!
Alternatives to fnm
NVM (Node version manager) is an alternative to
fnm that allows developers to install and manage their Node installs. Some sample commands include:
nvm use 18.15.0 #use a certain Node version nvm install --lts #install Node to local machine
When compared to
fnm, you might notice that it is far slower. Furthermore, this application doesn’t support Windows operating systems. As a workaround, The nvm team recommends nvm-windows, but it is not officially supported.
Similar to nvm, Volta is also a Node version management tool. Just like
fnm, it was also built with Rust, thus bringing stability and speed to the table. Moreover, it lets creators “pin” certain Node engines. This means that if there’s a project that relies on a certain Node install, Volta will automatically switch to that Node version to prevent instability issues in the stack.
volta install node # install latest Node LTS volta pin [email protected] # tell Volta that our project will use this node version
Since its launch, Fast Node Manager has become the default way to install Node on my computer. Although other alternatives like nvm and Volta exist,
fnm has always been my tool of choice because of its speed and simplicity.
Thank you so much for reading! Happy coding!
200’s only Monitor failed and slow network requests in productionDeploying a Node-based web app or website is the easy part. Making sure your Node instance continues to serve resources to your app is where things get tougher. If you’re interested in ensuring requests to the backend or third party services are successful, try LogRocket. https://logrocket.com/signup/
LogRocket is like a DVR for web and mobile apps, recording literally everything that happens while a user interacts with your app. Instead of guessing why problems happen, you can aggregate and report on problematic network requests to quickly understand the root cause.LogRocket instruments your app to record baseline performance timings such as page load time, time to first byte, slow network requests, and also logs Redux, NgRx, and Vuex actions/state. Start monitoring for free.