Skip to content

pnpm patch <name> requires node_modules/.modules.yaml to be present #8257

@Silic0nS0ldier

Description

@Silic0nS0ldier

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

9.4.0

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

  1. Ensure node_modules is not present
  2. Attempt to patch a package (e.g. pnpm patch typescript)
  3. Observe failure
 ERR_PNPM_PATCH_NO_LOCKFILE  No pnpm-lock.yaml found: Cannot patch without a lockfile

Describe the Bug

There are 2 issues I see here.

  1. The error is misleading. pnpm-lock.yaml does exist, node_modules may or may not (the deciding factor is node_modules/.modules.yaml).
  2. Patching relies on node_modules. This is an easy requirement to meet (just run pnpm i), it is inconvenient. Especially when pnpm has been relegated to the role of dependency resolver alone, like with build system integrations (in my case Bazel + Rules JS).

Expected Behavior

The patch workflow can run without needing node_modules.

Which Node.js version are you using?

20.14.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

Linux (Dev Container running on Docker)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions