02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Getting a Different Version of Node.js on Linux

Getting a Different Version of Node.js on Linux

In this tutorial, we will guide you through the process of getting a different version of Node.js on your Linux system. Managing multiple versions of Node.js can be helpful, especially if you're working on different projects that require different versions. This tutorial covers the use of nvm (Node Version Manager) and other methods for managing Node.js versions. Any critical updates since the original recording in 2016 have been added to ensure you have the most relevant information.

Step 1: Installing Node Version Manager (nvm)

The best way to manage multiple versions of Node.js on Linux is by using nvm. Node Version Manager allows you to easily install and switch between different Node.js versions.

  1. Install nvm by running the following command in your terminal:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
    

    This command will download and install nvm on your system.

  2. Load nvm into your current terminal session:

    source ~/.nvm/nvm.sh
    

    You may also need to restart your terminal for the changes to take effect.

Critical Update (2024): The latest version of nvm is v0.39.1, which has better compatibility and improved stability. Always check the nvm GitHub page for the latest version.

Step 2: Installing Different Versions of Node.js

With nvm installed, you can now use it to install any version of Node.js you need.

  1. Install a Specific Version of Node.js by running the command:

    nvm install 16
    

    Replace 16 with the version number you wish to install. For example, you can install Node.js version 18 by using nvm install 18.

  2. Check the Installed Versions:

    nvm list
    

    This will show all the versions of Node.js that you have installed on your system.

  3. Switch Between Versions:

    nvm use 16
    

    Use the version number that you want to activate for your current session. This allows you to switch between versions depending on the requirements of your project.

Note: As of 2024, it is recommended to use Node.js version 18 or higher for better performance and compatibility with the latest JavaScript features.

Step 3: Setting a Default Node.js Version

If you frequently use a particular version of Node.js, you can set it as the default version.

  1. Set Default Version:
    nvm alias default 16
    
    Replace 16 with the version you want to set as the default. This ensures that whenever you open a new terminal session, the specified version of Node.js will be used.

Step 4: Uninstalling a Node.js Version

If you no longer need a particular version of Node.js, you can easily uninstall it.

  1. Uninstall a Version:
    nvm uninstall 16
    
    This will remove the specified version from your system, freeing up space and reducing clutter.

Alternative Method: Using NodeSource

If you prefer not to use nvm, you can also install different versions of Node.js directly from NodeSource.

  1. Add NodeSource Repository:

    curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    

    Replace 16.x with the version you want to install.

  2. Install Node.js:

    sudo apt install -y nodejs
    

Critical Update (2024): While NodeSource is still a viable option, using nvm is now the recommended approach for development environments, as it provides better flexibility and easier version management.

Conclusion

In this tutorial, you learned how to manage different versions of Node.js on a Linux system using nvm and NodeSource. Using nvm is the preferred method for most developers, as it allows easy installation, switching, and management of multiple Node.js versions. This flexibility is especially useful when working on multiple projects with different requirements.

Make sure to always use the latest LTS version of Node.js for stability, and consider upgrading to newer versions to take advantage of the latest features and performance improvements.

Video Transcript

00:00Welcome to Essential Full Stack Development.
00:02The course that is gonna completely upgrade your career,
00:06full stack development is the hottest, most rewarding,
00:10and currently the most financially rewarding skill you wanna
00:13have under your belt.
00:15Now, before we get into
00:16what we're gonna cover in this course,
00:18I just wanna say my name is Ben Valla
00:20and this is a packed publishing production.
00:23With that said, this course is
00:26for you in most probability if you're watching this video,
00:29but under the assumption
00:31that you already know JavaScript, that's the only thing.
00:33The only prerequisite you must have
00:35before taking this course is you need to know JavaScript.
00:38You don't need to know anything else.
00:40We're gonna cover all the other foundations
00:42and fundamentals
00:43to get you into full stack development, right?
00:46So that's it, that's the prerequisites.
00:49So what are we gonna cover in this title?
00:51This title is revolutionary
00:53because it's really gonna cover all the foundations
00:56that are critical for you to be able to know, to be able
00:59to call yourself a full stack developer.
01:01So what does that include?
01:03So first of all, we're gonna, in the first chapter,
01:05set things up with basically getting node js
01:08and NPM up and running.
01:10In the second chapter, we're gonna go deep into the world
01:12of NPM and understand what package managers are
01:16and what specifically could you do with NPM, which is the
01:20critical technology that with it,
01:23you're building everything in full stack.
01:26Next, we're gonna dive deep into the world of NO js,
01:28where we'll get you familiar enough to understand
01:31how no jfs works,
01:33so you'll feel comfortable when you're developing
01:35in this environment.
01:37We're gonna also go deeper
01:39by taking a look at the express JS framework work,
01:42which is in a layer that sits on top of node js
01:45that makes things easier when it comes to anything
01:48that relates to building and working on a server.
01:52Last but not least, the most critical skill
01:54that you wanna wrap things up to be able to say that,
01:57you know, all the critical skills in full stack development
02:01is getting you familiar with MongoDB,
02:03or more accurately the technology behind it,
02:06which is no SQL.
02:07We're gonna understand what node no SQL is
02:10and literally learn the foundations to enable you
02:13to build your own databases.
02:15So by the end of this course, you're going to be a developer
02:19that is working on, on your server.
02:21You're gonna be building server, side code,
02:23client side code,
02:25and oso integrating into it, no SQL.
02:29So what are we co we,
02:30what are we gonna cover in this first chapter?
02:32So this first chapter is really all about
02:34setup and then the setup.
02:35We're gonna go through the configurations for Windows,
02:38the configurations for desktops in general, configurations
02:41for a server itself, namely a Linux server,
02:44and OTO specifically how to change the different versions
02:48of NPM and no gs, which are quite different than
02:51how it's done on a desktop.
02:54With that said, let's jump right into our first lecture.
02:56And in the first lecture we're gonna be focused
02:58on our Windows users.
03:00So if you are running on a Mac,
03:02you could stop this video already now
03:04and go on to the next video.
03:05But if you are a Windows user,
03:07what we're gonna do in this lecture is we're gonna help you
03:10make your operating system work more similarly
03:13to the way things work on a Linux and IO X, um, on a Mac,
03:18because all of the rest
03:20of the videos are gonna be focused on those users
03:22because the production files usually sit on a Linux,
03:26which their language is comparable
03:28and very similar to the way we work on uh, Mac.
03:31So with that said, for our Windows users in this lecture,
03:34we're gonna go ahead and set up a terminal,
03:36which will mimic the terminal that is available on a Mac
03:40and on a Linux operating system, making the,
03:43our Windows users have a similar setting
03:46to the remainder chapter.
03:47So let's jump right in into it.
03:49Windows users, let's see how we set things up to get
03:53things working the way that we're gonna be working
03:56with from the next chapter and onwards.
03:59Before we could start installing
04:01and working with Node js, we need to make sure
04:04that you have access to terminal.
04:07If you're working on Mac, you already have access
04:09to terminal, it's an application that runs on Mac Os.
04:13If you're running on any Linux device,
04:16you're probably familiar with the way you go
04:18to your Linux prompt, which will work the same way.
04:21Now when you're working on contrera on Windows It,
04:25you're going to discover that you don't have access
04:28to the same Linux commands as we have,
04:31and we'll be working with within this course
04:33and within most lectures and documentation on no js.
04:38So to join us, make sure that if you're running on Windows,
04:41you install, um, CYG win.
04:44I can't pronounce it. There's other applications
04:47that do the same thing,
04:48but what they do, it's a wrapper
04:49that mimics the behaviors on Linux.
04:52So go ahead and based on if you have, um,
04:55the link is gonna be in the description to this video.
04:58Um, make sure to install
05:00or update, see, well basically install the 32 bit version
05:04or the 62 64 bit version depending on your
05:07version of Windows.
05:09I'm gonna go ahead and install the 32 bit version
05:14and I'm gonna run it
05:21And once installation will complete, just follow the prompts
05:24and go ahead and go through the process of the installation.
05:29I'm gonna keep everything in its default
05:31and just click next, next, next
05:33until we get it downloaded and installed.
05:36Now once you have Sgu installed, um,
05:40and I'm gonna, it's a little bit outta my screen right now,
05:42but I'm gonna just go ahead
05:44and keep everything the way it is.
05:46I'm not gonna select any package and I'm gonna click on next
05:50and I'm gonna click on next and I'm gonna just go ahead
05:53and install whatever the defaults have been.
05:57So once in installation completes, uh,
05:59we're gonna set up the desktop, add it to the start
06:02or I'm gonna click your un finish.
06:04And once I'm done with this now,
06:06because I set everything up to be in the default,
06:09if you look at your prompt, you'll see that we
06:12on your desktop, you should have the CGU terminal.
06:16Now if I go ahead and double click on it,
06:18I'm gonna be entered into this terminal Now to make sure
06:22that everything is working is well.
06:27Basically, anytime that I actually mention and say terminal
06:30or say, go onto your terminal
06:32or you see me working in this in a prompt, make sure
06:35that you open the sequin terminal
06:37because we're gonna refer to it to the remainder
06:39of the course as terminal.
06:43In this lecture, we went ahead
06:45and saw how to set up our windows to have a terminal using
06:49seig swig, whatever it's called in the next lecture,
06:52we're gonna be operating system Ag stick
06:55as we go back into my Mac.
06:58And on the Mac itself, we're gonna go ahead
07:00and install no JS and NPM,
07:02but the actions that we're gonna be doing are gonna be the
07:04same as they're done on Windows.
07:07So we'll see in the next lecture when we set our NO JS
07:10and NPM Up.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!