1

What is npm CLI ?

 4 weeks ago
source link: https://www.geeksforgeeks.org/what-is-npm-cli/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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:

Screenshot-from-2024-03-04-20-08-18-(1)-min-(1)

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:

Screenshot-from-2024-03-04-20-23-01-(1)

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:

Screenshot-from-2024-03-04-20-31-12-(1)

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:

Screenshot-from-2024-03-04-20-37-22-(1)

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:

Screenshot-from-2024-03-04-20-47-43-(1)

Features pf npm CLI:

  • It is used to install,uninstall,update and list the packages (Package Management)
  • It is used to initialise and run a project (Project Management)
  • It ensures consistency in Node projects by working with package-lock.json file.
  • It has better built in security. Vulnerabilities can be scanned through ‘npm audit’ command and are fixed periodically.

Benefits of npm CLI:

  • npm cli allows a faster interaction to install or create projects
  • Packages can be installed in less time
  • It allows the developer to customise the necessary changes required.

“This course was packed with amazing and well-organized content! The project-based approach of this course made it even better to understand concepts faster. Also the instructor in the live classes is really good and knowledgeable.”- Tejas | Deutsche Bank

With our revamped Full Stack Development Program: master Node.js and React that enables you to create dynamic web applications.

So get ready for salary hike only with our Full Stack Development Course.

Last Updated : 22 Mar, 2024
Like Article
Save Article
Share your thoughts in the comments

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK