15 Sep, 2023
I recently reinstalled Fedora 38 on my laptop and needed NodeJS installed. I was going through and needed to install and update quite a few applications, and Node was stuck at version 16. I finally found a few additional articles on how to install a specific version of Node.
Typically you can run the following command, and it'll install the version of Node we'd like. You can specify a version as well. This method is installing from the Fedora Repository.
# Install default version $ sudo dnf install nodejs # Specify alternate version $ dnf module install nodejs:18/common
These methods did not work as for some reason I was only able to see the Node 16 LTS version. I was able to find how to add the NodeSource Repository by doing the following, but that has changed as well.
$ curl -sL https://rpm.nodesource.com/setup_lts.x | sudo bash - $ sudo dnf install nodejs
I tried running this but got that the install method is retired and sent me to a GitHub Link describing the new method of installing from the NodeSource repository
Before you install Node.js it is best to make sure your system is up to date. It could be possible that the version we need just needs to be updated.
$ sudo dnf upgrade --refresh
Running the command ensures your system checks for updates regardless of the last cache time. There is an optional step, which I did perform before running the Node.js install.
$ yum install gcc-c++ make
This part I'd say is optional, but I did do an uninstall of Node.js before continuing with the NodeSource install.
$ yum remove nodejs &&\ $ rm -r /etc/yum.repos.d/nodesource*.repo &&\ yum clean all
Now you will be able to add the Node.js nodesource repo and install v18.x.
$ sudo yum install https://rpm.nodesource.com/pub_18.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y $ sudo yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1
Now after install process you will be able to see the version of Node you have installed and get to work! I had to update my Node version that was done on a fresh install of Fedora 38 since projects are built and tested with v18.x.
$ node -v v18.17.1 $ npm -v email@example.com /usr/lib/node_modules/npm
At the time of installing the
npm version was 9.6.7, and version 10.x was available. Let's get that updated too.
$ npm install -g npm@latest $ npm -v 10.1.0
Now that we have installed the current LTS version of Node.js we can begin our development processes and get to work.
I hope this helps you like it did for me. After a clean install, it's times like this getting your environment set back up can be a little challenging, but we have to find the right processes.
Soon Node.js v18.x will be out of Active support and will need to move onto Node.js v20.
Once this happens, we should be able to follow along the same path to install v20. You might want to uninstall v18 first, but once I see this I'll figure out the best path forward to upgrade.
# installing Node.js v20.x $ sudo yum install https://rpm.nodesource.com/pub_20.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y $ sudo yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1
There is also a way to install Node.js using NVM (Node Version Manager), but for my use case I only have one version installed. If I did more development work or wanted to test versions before upgrading my main version, I can see where this process would be beneficial.
I have not tested this method out at this time, but you can read more as well: https://github.com/nvm-sh/nvm
If there are replies, they will show below.