How To Install Node.js on Ubuntu 22.04 LTS (Linux)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this video I'm going to show you how you can download and install and use node.js on your Ubuntu operating system now there are several different ways of installing and using node.js on your Ubuntu operating system and if you are a node.js developer let me show you at least two most important or most useful ways to install node.js now you can install node.js using apt-get install node.js and app get install npm but I don't prefer that way and let me tell you why because node.js releases regularly or timely the new version of node and it becomes painful to uninstall and reinstall the newer version of node.js when it comes out right so I'm going to show you a flexible way which will be useful and let me show you that right so watch the full video I'm going to show you two different ways and apt get install node is not one of them so first of all open your favorite browser and search for install node.js snap and snap is a newer way of installing packages on your Ubuntu operating system so just click on the first link which says install node on Linux right I'm going to click on this link and it's official website from canonical which is also the developer of Ubuntu right so it's not just any website it's a official way of installing packages now from here you can select any node version and you can see I have this uh channel 18 stable Channel 20 stable and all these versions right generally I go with the top most version which is uh 18 stable at the time of making this video I'm going to click on install and it's going to give me the command to install uh node using that Command right so you can see it's install 18 stable and I'm going to copy this command and then open the terminal so to open the terminal just press Ctrl alt t or you can go to the application and open the terminal from here once the terminal is open paste this command snap already comes on your Ubuntu operating system by default if you have the newer version of Ubuntu so you just need to give this command and then give the ubuntu's password and then press enter which is going to install the node.js using the snap once this command is successful you can see the version of node which is installed which is 18.16.0 let's go to the node.js official website and see what is the latest version there and you can see 18.16.0 LTS is the latest uh stable version right and that is the one we have installed so it's up to date version we have installed right so now let's check the version of node node hyphen hyphen version and hopefully it will give you the version node also comes with npm so let's check the version of npm and it'll give you the version of npm now uh any time when a newer version of node.js comes or any patch comes for this version Snaps are auto updating right so you will normally have a node.js installed for you on the same day on which official node.js version is released right so you don't need to worry about it so if the patches comes to this version uh you don't need to worry uh everything will be automatically updated if you want to update to a newer version let's say you want to update to a version 20 for node.js right what you can do here is you can give this command which is sudo snap and then refresh command and then the name of the package in our case it's node and then hyphen hyphen channel right and you can give the channel 20 here which means you want to install the version 20 of node.js right so you can go to the snap website and see which version is the latest version and then you can install that right you can see Channel 20 means 20 stable so when you click on 20 stable you can see hyphen hyphen channel is equal to 24 slash table classic right if you want to install different version you can do that just you need to change the channel here right so this is how you can upgrade or downgrade the node.js version using snap now one way I frequently use to switch between node.js version is not by switching the snap version but using a utility called NVM which is called node version manager so just go to your browser and search for install NVM and the first link which will appear here will be from this GitHub repository which is github.com forward slash NVM hyphen sh click on this NVM repository go down and here you will see installing and updating you can either copy this command or this command both will install the NVM right so you just need to copy one of these commands I'm going to use the curl command you can also use the wget command for your Ubuntu operating system and I'm going to go to the terminal paste this command and then press enter which is going to directly install NVM you don't need to do anything once NVM is installed you can just write NVM here and and right now it's not recognized NVM because I haven't read this text here it says close and open your terminal to start using NVM and run the following command for example you can run this NVM dare command for uh the setting for setting the NVM directory so I'm going to open the new terminal control shift T will open the new terminal here you can write NVM and you can see NVM command is recognized now now here I want to check the versions of NVM right so so now using NVM I want to check the versions of node right so let me clear the terminal so first of all here for NVM I'm going to write NVM and I want to list the current versions of node.js right I can just write NVM LS and you can see it says this arrow and redirect it to system system means whatever version of node.js is installed on your system and VM recognizes it and the current version which is set for NVM is this system version you can also list the versions which are available remotely so you can just write lists and then remote so list hyphen remote here and then press enter and it's going to give you the list of all the versions which you can install using NVM let's say I want to install the version let's say 18.10.0 right now the version is 18.16.0 right so let me show you the node version which is 18.164.0 and let's say I want to install the version different than 18.16.0 I can just write NVM install and the version I want to install right so I will go with the last LTS version which is a version 16.20.0 I can copy this version and then paste here okay so NVM install and then paste the version and you can see V is added in front of this version so just copy it from here press enter and it's going to install the version 16. and then NVM makes it really easy to switch between these node versions right once again I can just write NVM LS and it shows me now two versions one is 16.20.0 and other is the system version and the current selected version is 16.20.0 so I can just write node hyphen iPhone version and then press enter and you can see now the current version is 16.20.0 now in order to change this version you can only use this version or the system version so in order to use a version you need to install it first so write NVM use so right now I have 16.20.0 or system so I can switch to the system and I can copy and paste it here and then press enter and now I'm using the system version which is 18.16.0 so I can once again give this command and now I'm using 18.16.0 so I don't need to run the snap update or downgrade command to uh switch between node I can use NVM to switch between node versions right so this is how you can download and install node and npm on your Ubuntu operating system I hope you enjoyed this video and I will see you in the next video
Info
Channel: ProgrammingKnowledge
Views: 93,901
Rating: undefined out of 5
Keywords: Node.js, Tutorial, Introduction, Environment Setup, Node Package Manager, Event Emitters, JSON to JS Objects, Writing Stream, Piping Stream, Ubuntu 20.04, Ubuntu 20.04 LTS, Install Node.js, Install Node, Node.js on Ubuntu, Node.js on Ubuntu 20.04, Linux Mint, Linux Mint Debian
Id: KtTe_ckT3iM
Channel Id: undefined
Length: 11min 17sec (677 seconds)
Published: Fri Jun 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.