Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check that dependencies are install before running scripts #8585

@Nick-Mazuk

Description

@Nick-Mazuk

Contribution

Describe the user story

It's easy to begin development with the wrong dependencies installed. Here's some examples:

  • Switch branches, where the new branch has different dependencies
  • Pull the repo for the first time

Describe the solution you'd like

Normally you'd have to remember to run pnpm i in these scenarios. I'd like pnpm to "remember" for me.

Before I run a script in the "scripts" field of the package.json (or pnpm test, etc.), I'd like pnpm to check that the correct dependencies are installed then either:

  • Error out, notifying me that I should run pnpm i
  • Automatically install the dependencies for me (i.e., run pnpm i in the background).

Describe the drawbacks of your solution

  • This will increase the latency of every command. It may be possible to utilize caching to speed this up for subsequent pnpm invocations.
  • Automatically running pnpm i can pose security risks (because postinstall scripts can run arbitrary code), so doing this should be opt-in on the developer-level in my opinion.

Describe alternatives you've considered

Keep the status quo.

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