Overview

PNPM (Performant NPM) is a fast, disk space-efficient package manager for JavaScript. It uses a unique symlink-based approach to manage dependencies, which results in faster installs and reduced disk space usage compared to NPM.

PNPM ensures that multiple projects using the same dependency do not duplicate it on disk, thus saving space and speeding up the installation process.

Installation

There are multiple ways to install Pnpm. In this guide, we will show the three easiest methods for installing Pnpm. You can find information on other methods here.


Open your terminal and run this command

npm install -g pnpm

The above command will install Pnpm

Run this command to verify if Pnpm is installed

  pnpm -v

It should show something like v9.7.0

Usage

Initializing a Project

pnpm init

This command creates a package.json file in your project directory, which is used to manage the project's dependencies, scripts, and other metadata.


Installing a Package

pnpm install <package_name>

This command installs a package locally in your project, similar to NPM, but with performance and disk space optimizations.

Example

pnpm install react

This installs the react package.


Installing a Package Globally

pnpm install -g <package_name>

This command installs a package globally on your system, making it available from any directory.

Example

pnpm install -g typescript

This installs the typescript package globally.


Updating a Package

pnpm update <package_name>

This command updates a package to the latest version. If no package name is specified, it updates all project dependencies.

Example

pnpm update react

This updates the react package to its latest version.


Uninstalling a Package

pnpm uninstall <package_name>

This command removes a package from your project and updates the package.json and package-lock.json files accordingly.

Example

pnpm uninstall react

This uninstalls the react package.