Furthermore, npm allows its users to download packages, execute them, share code, enforce access restrictions, and manage multiple versions of their code efficiently.
The main objective of technical writing is to provide you with the skills to install the npm package on Ubuntu 22.04.
How to Install npm on Ubuntu 22.04?
The steps presented below illustrate how to install the npm package on your Ubuntu 22.04.
Step 1: Verify npm Package
Run the command from the terminal to check if you have npm already installed:
Step 2: Install npm Package
The command provided below will install the npm package along with the required libraries and dependencies on your Ubuntu machine:
sudo apt install npm -y
The above snapshot indicates that the npm package is installed successfully.
Step 3: Confirmation
Using the command followed by the “-v” option will display the installed version of the npm package:
Step 4:Test npm Installation
The following command is attached below for your reference to test the npm package. Simply, copy and run from your terminal to initiate the testing process:
curl -fsSL https://deb.nodesource.com/test | bash -
The above output indicates that the npm is working correctly and is ready to use.
How to Use npm on Ubuntu 22.04?
If you are new to npm and want to explore more about the package, run the command from the Ubuntu terminal:
The “npm –help” command displayed all the basic commands and usage of the package.
Search for npm Packages
You can search for your desired package within the npm repository by using the following command:
npm search web framework
Install “express” via npm
To install the express package from the npm repository, run the command in the following manner:
npm install express
It can be seen in the above message that the “express” package has been installed without any error.
List the Installed Package
To see the list of available npm packages, execute the below command:
So far, we have one package installed in our Ubuntu operating system.
View npm’s Detailed Information
The syntax provided below will be used to display the detailed information about the npm package:
npm view express
Based on the provided screenshot, you can see information about the keywords, dependencies, version, and other details.
You can also remove an already installed package from your system using the “npm uninstall” command followed by the package name, such as “express”:
npm uninstall express
According to the mentioned screenshot output, it is displayed that “express” has been successfully removed from your Ubuntu 22.04 system.
How to Uninstall npm from Ubuntu 22.04?
Step 1: Purging npm Package
Using the command presented below will completely remove all npm package files and dependencies from the system.
sudo apt purge npm -y
The output displayed in the screenshot indicates that the npm package, along with its configuration files, has been successfully removed from your Ubuntu machine.
Step 2: Confirmation
To retrieve the information about the npm package such as installation details and version etc, run the following command:
According to the above results, it appears that the npm package is no longer available on your Ubuntu 22.04 machine.
Install the npm package on the Ubuntu machine using the simple command “sudo apt install npm -y”. npm is a software tool that comprises distinct components such as the website, the Command Line Interface (CLI), and the registry. It also offers a large collection of free, open-source libraries, frameworks, and tools.
Developers can effortlessly install, manage, and update them in their projects. With the help of this educational post, you have the confidence and ability to manage npm packages for your development projects on Ubuntu 22.04.