Search code examples
pnpm

pnpm add <package_name> updating all packages


when running pnpm add <package_name> all my packages get updated, same thing happens when running pnpm install <package_name>.

is there a flag or configuration I can use to stop this from happening?

using pnpm version 7.14.2.


Solution

  • From https://pnpm.io/cli/install :

    --prefer-offline

    Default: false

    Type: Boolean

    If true, staleness checks for cached data will be bypassed, but missing data will be requested from the server. To force full offline mode, use --offline.

    From the source code: https://github.com/pnpm/pnpm/blob/eacff33e4f77cf550e4da4f3e7f4506200a93154/packages/pnpm/src/main.ts#L228-L238

        if (
          config.updateNotifier !== false &&
          !isCI &&
          !selfUpdate &&
          !config.offline &&
          !config.preferOffline &&
          !config.fallbackCommandUsed &&
          (cmd === 'install' || cmd === 'add')
        ) {
          checkForUpdates(config).catch(() => { /* Ignore */ })
        }
    

    pnpm install --prefer-offline <package_name> will prevent pnpm from checking for updates, but will still request the data you need from the server.