Before to continue with the installation, first let’s review how is not recommend to install Node.js.

How not to install Node.js
Node can be installed in different ways in macOS, Windows and Linux Operating systems. It is commonly installed using an OS official or unofficial package manager. For example, you can use apt-gen on Debian/Ubuntu. On macOS, you might use Brew. For Windows, Chocolatey is a option to install it. Nonetheless, according to the Introduction to Node.js (LFW111) it is not recommended to use it. Why? Maybe you’re asking yourself, let me give a few points of why.
- Outdated versions: Package managers often lag behind Node.js frequent updates, resulting in missed features, bug fixes, and security patches.
- Inconsistent file placement: Binary and configuration file locations vary between OS package managers, causing compatibility issues and confusion.
- Security risks with sudo: Installing global npm modules requires
sudoon non-Windows systems. This action poses security risks by granting root privileges to third-party libraries.
A different way to install Node is directly from the official Node.js website. Yet, on macOS and Linux, sudo is still required to install global libraries, which is not ideal. Thus, it is recommended to completely uninstall Node if it was installed via a package manager or directly from the website.

How to install Node.js using fnm
No matter if you’re on Windows, macOS, or Linux, we’ll explore a more efficient way to install Node. You can use a version manager or install it directly from the website. Again, before proceeding, you should fully uninstall Node. This is advised if Node was previously installed using an OS package manager or directly from the official website.
The recommended way to install Node is using a Node version manager called fnm (Fast Node Manager). This way is recommended for a streamlined installation process.
What is fnm?
fnm is a lightweight and efficient Node.js version manager that simplifies handling multiple Node.js versions. It allows you to install, uninstall, and automatically switch Node versions depending on the directory you’re working in. Is compatible across macOS, Windows, and Linux, fnm also supports popular shells like Bash, Zsh, Fish, PowerShell, and the Windows Command Prompt. Built for speed, it works seamlessly with .node-version and .nvmrc files, making it a perfect fit for managing Node.js versions effectively.
If you need to know more details and documentation about fnm, you can refer to the fnm GitHub Repository.
Installing fnm
Let’s begin, First we need to install fnm to install Node. If you have curl installed, use the following command to install fnm using the install script:
$ curl -fsSL https://fnm.vercel.app/install | bash
If you do not have curl installed, you can manually download the script from the provided URL and execute it; or if you prefer a manual installation method or need more information, please visit the fnm repository page.
Additionally, you can find instructions for setting up auto-completions for the terminal you’re using in the fnm repository page.
After the installation, verify that fnm is working correctly by running the following command:
$ fnm --version
The expected output should be fnm 1.33.1. If this command fails on Linux, try restarting the terminal by closing and reopening it or the SSH session and then running the command again. For troubleshooting information, refer to the original repository.
If, upon restarting the terminal, you encounter a “Command ‘fnm‘ not found” error, it is likely that the $PATH for the fnm executable was not properly set during the installation process. You can easily set it by entering the following command in the terminal:
$ export PATH="$HOME/.local/share/fnm:$PATH"
With the version manager successfully installed, let’s proceed to install the specific Node version we’ll be using for this course:
$ fnm install --lts
This command will install the latest LTS (Long-Term Support) version of Node.
Installing Node
It is important to note that the exact numbers at the end of the version may vary. So, you can install the latest available version of Node by supplying the following command to fnm:
$ fnm install --latest
To verify that Node is installed and check its version, use the following command:
$ node -v
Congratulations! You now have the proper setup on your macOS or Linux machine.
Happy Learning!!!


Leave a comment