pnpm: Could not apply patch

pnpm version:

7.12.2

Code to reproduce the issue:

pnpm patch @typescript-eslint/scope-manager@5.40.0
# edit
pnpm patch-commit /tmp/xxx
pnpm i

Expected behavior:

Patch success

Actual behavior:

Progress: resolved 3094, reused 3018, downloaded 0, added 0, done
 ERR_PNPM_PATCH_FAILED  Could not apply patch /root/dev/baas/patches/@typescript-eslint__scope-manager@5.40.0.patch to /root/dev/baas/node_modules/.pnpm/@typescript-eslint+scope-manager@5.40.0_xszkkb5ilmmz437fkjphr2b2n4/node_modules/@typescript-eslint/scope-manager

Additional information:

Patch file:

diff --git a/dist/referencer/Referencer.js b/tmp/43077298d14f9074bcb83e3ca1dcb2eb/dist/referencer/Referencer.js
index 758822502cefd798fe8e0acaa8362c7ad1451899..3518a00cad1cf48da790705c3416b1538a2495f9 100644
--- a/dist/referencer/Referencer.js
+++ b/tmp/43077298d14f9074bcb83e3ca1dcb2eb/dist/referencer/Referencer.js
@@ -58,6 +58,9 @@ class Referencer extends Visitor_1.Visitor {
     }
     populateGlobalsFromLib(globalScope) {
         for (const lib of __classPrivateFieldGet(this, _Referencer_lib, "f")) {
+            // Temporary Workaround for error when using `@tsplus/installer@0.0.135`:
+            // Parsing error: Invalid value for lib provided: tsplus
+            if (lib === "tsplus") continue;
             const variables = lib_1.lib[lib];
             /* istanbul ignore if */ if (!variables) {
                 throw new Error(`Invalid value for lib provided: ${lib}`);
  • node -v prints: v18.9.0

  • Windows, macOS, or Linux?: WSL2 Centos in Windows

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 5
  • Comments: 15 (1 by maintainers)

Most upvoted comments

I am also having this problem: a patch that patch-packages is happy with fails under pnpm patchedDependencies, and frustratingly, pnpm gives absolutely no information beyond that it failed.

Using pnpm v8.

Doesn’t resolve the issue but I fixed this by changing

  "pnpm": {
    "patchedDependencies": {
      "package@version": "patches/package@version.patch"
    }
  }

to

  "pnpm": {
    "patchedDependencies": {
      "package": "patches/package.patch"
    }
  }

I’m using shamefully-hoist=true in .npmrc, maybe related?

Did you manage to solve this? I cannot reproduce it.

New patch entry in package.json:

  "pnpm": {
    "patchedDependencies": {
      "@typescript-eslint/scope-manager@5.40.1": "patches/@typescript-eslint__scope-manager@5.40.1.patch"
    }
  }

patch file looks like this:

diff --git a/dist/referencer/Referencer.js b/dist/referencer/Referencer.js
index 758822502cefd798fe8e0acaa8362c7ad1451899..03b19d558fe3622dd34bbac143b791fb6134d1ad 100644
--- a/dist/referencer/Referencer.js
+++ b/dist/referencer/Referencer.js
@@ -58,6 +58,9 @@ class Referencer extends Visitor_1.Visitor {
     }
     populateGlobalsFromLib(globalScope) {
         for (const lib of __classPrivateFieldGet(this, _Referencer_lib, "f")) {
+            // Temporary Workaround for error when using `@tsplus/installer@0.0.135`:
+            // Parsing error: Invalid value for lib provided: tsplus
+	    if (lib === "tsplus") continue;
             const variables = lib_1.lib[lib];
             /* istanbul ignore if */ if (!variables) {
                 throw new Error(`Invalid value for lib provided: ${lib}`);