How to install Nodejs and Npm in Ubuntu 22.04
Node. js is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It's used for traditional web sites and back-end API services like web App or Mobile App. But it was developed with real-time, push-based architectures in mind. Node is useful for developing applications that require a persistent connection from the browser to the server and is often used for real-time applications such as chat, news feeds and web push notifications.
Npm is its default package manager which can be used to install node packages and their dependencies.
1. Update the Package:
apt update command is used to update the Package. Open your terminal window and execute the below command. Enter your password to proceed further.It shows the list of updated available, if you want to update the entire list press 'y' to continue.
$ sudo apt update
2. Install nodejs and npm:
The apt command install Nodejs, Npm and all of thier required dependencies.
$ sudo apt install nodejs npm
3. Verify Installed version:
To verify the installation and to check the installed version, use the following command.
$ npm -v
4. Check the path of the Nodejs and Npm:
To check the installed path of the node and npm use the following commands.
$ whereis node
node: /usr/bin/node /usr/include/node /usr/share/man/man1/node.1.gz
$ whereis npm
npm: /usr/bin/npm /usr/share/npm /usr/share/man/man1/npm.1.gz