When it comes to installing Node.js on a development machine, you would normally install the environment using these steps:
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:
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:
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
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
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.
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
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
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!
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 node@14 # 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!
Deploying 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.
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.
CRDTs, or conflict-free replicated data types, is a concept that underlies applications facing the issue of data replication across a […]
We explore the fusion of TensorFlow and Rust, delving into how we can integrate these two technologies to build and train a neural network.
SignalDB enables automatic data synchronization between your components and a local in-memory or persistent database.