Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't patch package #300

Comments

@potatoengineer
Copy link

Just installed patch-package@6.4.6 and modified my package in node_modules and tried to run npx patch-package lottie-react-native but ended up with error.

npx patch-package lottie-react-native
patch-package 6.4.6
• Creating temporary folder
• Installing lottie-react-native@3.5.0 with npm
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 17928,
  stdout: null,
  stderr: null,
  error: null
}

/Users/name/folder/appName/node_modules/patch-package/dist/makePatch.js:218
        throw e;
        ^
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 17928,
  stdout: null,
  stderr: null,
  error: null
}
@ds300 ds300 closed this as completed in 2e400e0 Mar 12, 2021
@ds300
Copy link
Owner

ds300 commented Mar 12, 2021

Thanks for the report! ❤️

Fixed in https://github.com/ds300/patch-package/releases/tag/v6.4.7

@lucaszhu2zgf
Copy link

lucaszhu2zgf commented Jun 18, 2021

still get the same error at @v6.4.7 @ds300

patch-package 6.4.7
• Creating temporary folder
• Installing ant-design-vue@2.1.6 with npm
{
status: 254,
signal: null,
output: [ null, null, null ],
pid: 38727,
stdout: null,
stderr: null,
error: null
}

/Users/zhuguifeng/Documents/webank/init/node_modules/patch-package/dist/makePatch.js:218
throw e;
^
{
status: 254,
signal: null,
output: [ null, null, null ],
pid: 38727,
stdout: null,
stderr: null,
error: null
}

@magicwenli
Copy link

still get the same error at @v6.4.7 @ds300

patch-package 6.4.7
• Creating temporary folder
• Installing ant-design-vue@2.1.6 with npm
{
status: 254,
signal: null,
output: [ null, null, null ],
pid: 38727,
stdout: null,
stderr: null,
error: null
}

/Users/zhuguifeng/Documents/webank/init/node_modules/patch-package/dist/makePatch.js:218
throw e;
^
{
status: 254,
signal: null,
output: [ null, null, null ],
pid: 38727,
stdout: null,
stderr: null,
error: null
}

I met it when doing npx patch-package showdown-highlight

@joeldenning
Copy link

I still see this with patch-package@6.4.7. I ran pnpm exec patch-package vue-router and got the error with status 1

@AlonsoSalas
Copy link

Same error with "patch-package": "^6.4.7". I ran npx patch-package @strapi/admin and I got

{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 22699,
  stdout: null,
  stderr: null,
  error: null
}

/Users/alonsosalas/Globant/Cerifi/authoring/node_modules/patch-package/dist/makePatch.js:218
        throw e;
        ^
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 22699,
  stdout: null,
  stderr: null,
  error: null
}```

@skag27
Copy link

skag27 commented Mar 1, 2022

same error with npx patch-package export-from-json

@Strate
Copy link

Strate commented Apr 21, 2022

I had a problem with package react-native-track-player. For my case it was an error while command npm install running inside temporary folder, which was caused by using Apple M1 processor. Error is:

node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Microsoft/ApplicationInsights-node.js-native-metrics/releases/download/v0.0.7/native_metrics-v0.0.7-node-v83-darwin-arm64-unknown.tar.gz

After some debugging, I realized that patch-package picking npm version 2, which always installs all peerDependencies, which resulting to this error.

After digging for a while, I found that I have a package latest installed for unknown reason, which depends on npm@2, and patch-package pick that npm from node_modules, instead of system-wide npm.

Removing latest package fixed my problem.

@Baskerville42
Copy link

The same error for npx patch-package @react-native-community/cameraroll
version 6.4.7

@tonyjaimep
Copy link

@Strate

For my case it was an error while command npm install running inside temporary folder

How did you get access to this error?

@Strate
Copy link

Strate commented May 10, 2022

@Strate

For my case it was an error while command npm install running inside temporary folder

How did you get access to this error?

First, I installed patch-package to dependencies: npm install patch-package

Then, go to node_modules/patch-package/dist/makePatch.js, find lines like spawnSafe_1.spawnSafeSync(npm, ["i", "--force"], {, and change stdio: "ignore", to stdio: "inherit", or stdio: "pipe",.

@mwyatt896
Copy link

mwyatt896 commented Sep 8, 2022

Ran into this same issue but with yarn instead of NPM.

Had a yarn package I wanted to patch that had a separate dependency that was of a different version than specified in the yarn package. Yarn default behavior is to let you choose which version on to install upon yarn installation, but this was not happening in the makePatch.js file.

So per @Strate - we added stdio: "inherit" to the makePatch.js file when yarn is used (line 72) and then patch-package'd patch-package with this change. This then bypassed the version issue when patch-package was trying to run the yarn install function in makePatch.js and allowed us to make the patch file

@deorst
Copy link

deorst commented Dec 1, 2022

I ran into this issue trying to run yarn patch-package <package_name> in vscode terminal.
It failed, but for some reason it mac's terminal it worked fine without any changes applied to patch-package.
I checked and the node and yarn versions were same between both terminals.

@AdamZaczek
Copy link

In case you find this issue:

nvm use 16 && npx patch-package <package_name>

Happy new year!

@typenoob
Copy link

Just check if you are attempting to create file in your system path.Remember to use root identity for npm install/npx patch-package
sudo su

@penghuili
Copy link

@Strate

For my case it was an error while command npm install running inside temporary folder

How did you get access to this error?

First, I installed patch-package to dependencies: npm install patch-package

Then, go to node_modules/patch-package/dist/makePatch.js, find lines like spawnSafe_1.spawnSafeSync(npm, ["i", "--force"], {, and change stdio: "ignore", to stdio: "inherit", or stdio: "pipe",.

thanks for the tip.

the reason this happens to me is, i changed the registry in ~/.npmrc to my company's private registry, which doesn't have the library that i want to patch, and patch-package seems always read the .npmrc file in the root folder.

after changing the registry back to the default one (registry=https://registry.npmjs.org/), everything starts working.

@agfe2silver
Copy link

agfe2silver commented Aug 29, 2023

@Strate

For my case it was an error while command npm install running inside temporary folder

How did you get access to this error?

First, I installed patch-package to dependencies: npm install patch-package

Then, go to node_modules/patch-package/dist/makePatch.js, find lines like spawnSafe_1.spawnSafeSync(npm, ["i", "--force"], {, and change stdio: "ignore", to stdio: "inherit", or stdio: "pipe",.

In my case, 'yarn' does not work', but finally I chaged yarn with npx.
With above tip, npx works fine.

@kasunprabath98
Copy link

kasunprabath98 commented Jul 9, 2024

i am using Yarn and path package v8.0.0. Still encountering this issue in Node v20.5.0 . Can anyone help

@quangtuan28200
Copy link

quangtuan28200 commented Jul 18, 2024

I got the same error
before I use yarn patch-package <package-name>
after use npx patch-package <package-name> and work now

@GhayoorUlHaq
Copy link

@Strate

For my case it was an error while command npm install running inside temporary folder

How did you get access to this error?

First, I installed patch-package to dependencies: npm install patch-package

Then, go to node_modules/patch-package/dist/makePatch.js, find lines like spawnSafe_1.spawnSafeSync(npm, ["i", "--force"], {, and change stdio: "ignore", to stdio: "inherit", or stdio: "pipe",.

Using yarn, I also needed to remove "--ignore-engines" as well. So,
replace this code

 spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--ignore-engines"], {
                    cwd: tmpRepoNpmRoot,
                    logStdErrOnError: false,
                });

to

spawnSafe_1.spawnSafeSync(`yarn`, ["install"], {
                    cwd: tmpRepoNpmRoot,
                    logStdErrOnError: false,
                    stdio: "inherit",
                });

Thanks @Strate

@c-info
Copy link

c-info commented Aug 16, 2024

having the same issue on Yarn and path package v8.0.0. I am still encountering this issue in Node v20.5.0.

/node_modules/patch-package/dist/makePatch.js:396
throw e;
^
{
status: 1,
signal: null,
output: [ null, null, null ],
pid: 28924,
stdout: null,
stderr: null,
error: null
}

@thakkur
Copy link

thakkur commented Aug 19, 2024

I resolved the issue by creating a patch package for patch-package 😂
Patch name: patch-package+8.0.0.patch

diff --git a/node_modules/patch-package/dist/makePatch.js b/node_modules/patch-package/dist/makePatch.js
index d8d0925..a292026 100644
--- a/node_modules/patch-package/dist/makePatch.js
+++ b/node_modules/patch-package/dist/makePatch.js
@@ -115,12 +115,12 @@ function makePatch({ packagePathSpecifier, appPath, packageManager, includePaths
                 fs_extra_1.copySync(rcPath, path_1.join(tmpRepo.name, rcFile), { dereference: true });
             }
         });
-        if (packageManager === "yarn") {
+        if (packageManager === "npm") {
             console_1.default.info(chalk_1.default.grey("•"), `Installing ${packageDetails.name}@${packageVersion} with yarn`);
             try {
                 // try first without ignoring scripts in case they are required
                 // this works in 99.99% of cases
-                spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--ignore-engines"], {
+                spawnSafe_1.spawnSafeSync(`npm`, ["install", "--ignore-engines"], {
                     cwd: tmpRepoNpmRoot,
                     logStdErrOnError: false,
                 });
@@ -128,7 +128,7 @@ function makePatch({ packagePathSpecifier, appPath, packageManager, includePaths
             catch (e) {
                 // try again while ignoring scripts in case the script depends on
                 // an implicit context which we haven't reproduced
-                spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--ignore-engines", "--ignore-scripts"], {
+                spawnSafe_1.spawnSafeSync(`npm`, ["install", "--ignore-engines", "--ignore-scripts"], {
                     cwd: tmpRepoNpmRoot,
                 });
             }

@chr4ss12
Copy link

chr4ss12 commented Aug 20, 2024

still an issue:

npx patch-package react-native-mmkv-storage
patch-package 8.0.0
• Creating temporary folder
• Installing react-native-mmkv-storage@0.3.7 with npm
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 2140,
  stdout: null,
  stderr: null,
  error: null
}

/node_modules/patch-package/dist/makePatch.js:395
        throw e;
        ^
{
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 2140,
  stdout: null,
  stderr: null,
  error: null
}

Node.js v21.7.3

with the help of @Strate I managed to get the full error, and I've had to modify the

spawnSafe_1.spawnSafeSync(npm, ["i", "--force"]

to also add '--legacy-peer-deps'

@kingkongqn4444
Copy link

I resolved the issue by creating a patch package for patch-package 😂 Patch name: patch-package+8.0.0.patch

diff --git a/node_modules/patch-package/dist/makePatch.js b/node_modules/patch-package/dist/makePatch.js
index d8d0925..a292026 100644
--- a/node_modules/patch-package/dist/makePatch.js
+++ b/node_modules/patch-package/dist/makePatch.js
@@ -115,12 +115,12 @@ function makePatch({ packagePathSpecifier, appPath, packageManager, includePaths
                 fs_extra_1.copySync(rcPath, path_1.join(tmpRepo.name, rcFile), { dereference: true });
             }
         });
-        if (packageManager === "yarn") {
+        if (packageManager === "npm") {
             console_1.default.info(chalk_1.default.grey("•"), `Installing ${packageDetails.name}@${packageVersion} with yarn`);
             try {
                 // try first without ignoring scripts in case they are required
                 // this works in 99.99% of cases
-                spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--ignore-engines"], {
+                spawnSafe_1.spawnSafeSync(`npm`, ["install", "--ignore-engines"], {
                     cwd: tmpRepoNpmRoot,
                     logStdErrOnError: false,
                 });
@@ -128,7 +128,7 @@ function makePatch({ packagePathSpecifier, appPath, packageManager, includePaths
             catch (e) {
                 // try again while ignoring scripts in case the script depends on
                 // an implicit context which we haven't reproduced
-                spawnSafe_1.spawnSafeSync(`yarn`, ["install", "--ignore-engines", "--ignore-scripts"], {
+                spawnSafe_1.spawnSafeSync(`npm`, ["install", "--ignore-engines", "--ignore-scripts"], {
                     cwd: tmpRepoNpmRoot,
                 });
             }

it worked for me, very helpful

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