Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what the different between `pnpm install` and `pnpm add`?

I am work on monorepo stuff, and found that some guys use pnpm install to install packages in workspace, but some other use pnpm add.

in the pnpm docs, its seem like the same between add and install command, but there are some different options like --offline (for install)、--workspace(for add), and if I use pnpm install [pkg name] --workspace, its work normally.

so what the different between pnpm install and pnpm add?

like image 737
Nauxscript Avatar asked Sep 08 '25 00:09

Nauxscript


2 Answers

There is not much difference between them. In most cases they are interchangeable:

pnpm install <args?>: without args it will scan and install all the modules listed in pnpm-lock.yaml, in case of args it works as pnpm add

pnpm add <args>: It will install one more package.

if choose yes i will use pnpm add because it is new modern syntax that supports all package managers (npm add, yarn add)

like image 116
Tachibana Shin Avatar answered Sep 09 '25 13:09

Tachibana Shin


Basically as per their docs:


We need to use pnpm add when we want to add a new dependency to our project


We will be needing to use pnpm install when we have an existing project with the lockfile and we want to install all dependencies from the lockfile.


For more information please refer to the official docs:

PNPM Add Docs
PNPM Install Docs

like image 36
udoyhasan Avatar answered Sep 09 '25 13:09

udoyhasan