Open In App

What is npm CLI ?

npm CLI is a combination of words where npm refers to Node Package Manager and CLI refers to the Command Line Interface . Using the command line we are trying to access the packages and dependencies of the NodeJS. npm CLI provides different commands for developers to install, delete, and manage.

npm CLI commands:

Here is a list of a few commands with their descriptions.

Command

Description

npm install

Install the dependencies that a project needs in package.json

npm install <package>

Install the specific package required for the project

npm update

It checks for updates and install the latest version

npm update <package-name>

It is used to update the latest version of that package

npm init -y

Initialise node by creating package.json file

npm ls

List all the packages in current project

1. npm install command:

This command is used to install all the dependencies needed for a project. It also installs their modules



npm install

Output:

2. ‘npm install <packagename>’ command:

This command will only install the specified package mentioned. Other packages cant be install. Here we are installing the express modules.

npm install express

Output:

3. ‘npm update’ command:

This command is used to update the packages that has outdated version. Updating packages periodically will ensure proper functionality without errors

npm update

Output:

4. ‘npm init -y’ command:

This command is major one . By executing , it will create a package.json file . package.json file contains all the basic info about the project.

npm init

Output:

5. ‘npm ls’ command :

This command is used to list all the packages in current project. If no files are found it returns empty

npm ls

Output:

Features pf npm CLI:

Benefits of npm CLI:


Article Tags :