Search code examples
javascriptmonorepopnpm

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?


Solution

  • 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)