Skip to content

Add ‑‑no‑save CLI option for the pnpm add command #2020

Closed as not planned

Description

@ExE-Boss

pnpm version:

v4.0.0-2

Code to reproduce the issue:

> pnpm add --no-save <temp-package>

Expected behavior:

<temp-pacakge> is installed but package.json is not altered (like the default behaviour of npm add <temp‑package>.

This is useful when using dts‑gen to generate type definition stubs for DefinitelyTyped:

> pnpm add --no-save <temp-package>
> dts-gen --dt --module <temp-package>
> pnpm uninstall <temp-package>

Actual behavior:

package.json is modified even when ‑‑no‑save is provided.

Relevant issues:

Additional information:

  • node -v prints: v12.10.0
  • Windows, OS X, or Linux?: All

Activity

  1. zkochan commented on Sep 19, 2019

    @zkochan
    Member

    pnpx dts-gen --dt module <temp-package> won't work?

  2. ExE-Boss commented on Sep 19, 2019

    @ExE-Boss
    MemberAuthor

    No, because dts‑gen needs the <temp‑package> to be installed.

    Also, it´s:

    pnpx dts-gen --dt --module <temp-package>
    
  3. zkochan commented on Sep 19, 2019

    @zkochan
    Member

    There was a discussion about it here also: #1237

    I don't think it is worth adding but I don't have objections. However, --no-save will also need to prevent saving changes to the wanted lockfile (changes should be still done to node_modules/.pnpm-lock.yaml). And these not saved deps will be removed on running pnpm install

  4. ExE-Boss commented on Aug 31, 2020

    @ExE-Boss
    MemberAuthor

    @zkochan
    Now that save = false is supported in .npmrc, it should be possible to enable support for the ‑‑no‑save CLI option for pnpm add.

  5. zkochan commented on Aug 31, 2020

    @zkochan
    Member

    One change is still needed. The lockfile should not be modified when no save is set

  6. soundstep commented on Oct 6, 2020

    @soundstep

    I think I need that one as well, to create a script that install peer dependencies packages in a monorepo. This would prevent multiple copies of a package as we were using the devDependencies to install peerDependencies (like people do with a single package repo).

    Any update on the implementation?

  7. shellscape commented on Feb 5, 2021

    @shellscape
    Contributor

    For @rollup/plugin-typescript we have to simulate a user not having a particular dependency during a test and are using execa to remove and then add the dependency back. The kicker is that the particular dep is a workspace root dependency, and we'd like to keep it that way. We've resorted to running git checkout pnpm-lock.yml after adding the dependency back. It's not a burdensome extra step, but a --no-save option would come in handy, and I'm leveraging that in a few other webpack plugins I maintain to run v4 and v5 tests without effecting the repo's package and package-lock files.

  8. Camo30 commented on Jul 5, 2021

    @Camo30

    @zkochan I need that one as well: to install temporary needed packages in a monorepo without modifying the package file. Currently a workaround is necessary to accomplish this and it would be great to get rid of that.

  9. 0liver commented on Feb 8, 2023

    @0liver

    Now that save = false is supported in .npmrc, it should be possible to enable support for the ‑‑no‑save CLI option for pnpm add.

    @ExE-Boss Please link to the docs for this feature because I cannot find it here: https://pnpm.io/npmrc.

  10. antitoxic commented on Oct 27, 2024

    @antitoxic
    Contributor

    Adding this for future reference, in our project we have some weird cases where we need such transient installs so we use:

    npm_config_save=false npm_config_lockfile=false pnpm add/install ......

    which doesn't touch the lock file.

  11. silverwind commented on Sep 4, 2025

    @silverwind

    Duplicate of #1237.

  12. zkochan commented on Sep 19, 2026

    @zkochan
    Member

    Closing as a duplicate of #1237 (2018-06-21), which is the older report of the same thing.

    Both ask for --no-save: install or add a package without writing it into package.json.

    Follow #1237 for this. If you think the two differ in a way that matters, say so here and we will reopen.


    Written by an agent (Claude Code, claude-opus-5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions