The Front-End
Package Managers
Basic npm Commands

Basic npm Commands Guide

  1. Installing Packages Locally and Globally
  2. Updating and Uninstalling Packages
  3. Uninstalling Globally

Installing Packages Locally and Globally

Installing Locally:

To install a package locally, meaning it is specific to your current project, use the following command:

npm install <package-name>

Example:

npm install lodash

This installs the "lodash" package and adds it to your project's node_modules folder.

Installing Globally:

To install a package globally, making it available across your entire system, use the -g flag:

npm install -g <package-name>

Example:

npm install -g nodemon

This installs "nodemon" globally, allowing you to use it as a command-line tool.

Updating and Uninstalling Packages

Updating Packages:

To update a package to its latest version, use the following command:

npm update <package-name>

Example:

npm update lodash

This updates the "lodash" package to its latest version.

Uninstalling Packages:

To uninstall a package, removing it from your project or system, use the following command:

npm uninstall <package-name>

Example:

npm uninstall nodemon

This removes the globally installed "nodemon" package.

Uninstalling Globally:

To uninstall a globally installed package, use the -g flag:

npm uninstall -g <package-name>

Example:

npm uninstall -g nodemon

This removes the globally installed "nodemon" package.

These basic npm commands empower developers to manage packages effectively, whether they're working on a specific project or making tools available system-wide. Understanding these commands is fundamental for a smooth development experience and maintaining up-to-date and well-organized projects.