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
?
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
)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With