patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

Can't patch package

Open potatoengineer opened this issue 5 years ago • 31 comments

Just installed [email protected] 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 [email protected] 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
}

potatoengineer avatar Mar 12 '21 07:03 potatoengineer

Thanks for the report! ❤️

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

ds300 avatar Mar 12 '21 16:03 ds300

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

patch-package 6.4.7 • Creating temporary folder • Installing [email protected] 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 }

lucaszhu2zgf avatar Jun 18 '21 07:06 lucaszhu2zgf

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

patch-package 6.4.7 • Creating temporary folder • Installing [email protected] 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

wesleyel avatar Jul 16 '21 07:07 wesleyel

I still see this with [email protected]. I ran pnpm exec patch-package vue-router and got the error with status 1

internettrans avatar Jul 28 '21 04:07 internettrans

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
}```

AlonsoSalas avatar Feb 17 '22 13:02 AlonsoSalas

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

skag27 avatar Mar 01 '22 09:03 skag27

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.

Strate avatar Apr 21 '22 14:04 Strate

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

Baskerville42 avatar May 02 '22 13:05 Baskerville42

@Strate

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

How did you get access to this error?

tonyjaimep avatar May 04 '22 15:05 tonyjaimep

@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",.

Strate avatar May 10 '22 07:05 Strate

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

mwyatt896 avatar Sep 08 '22 17:09 mwyatt896

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.

deorst avatar Dec 01 '22 09:12 deorst

In case you find this issue:

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

Happy new year!

AdamZaczek avatar Dec 31 '22 02:12 AdamZaczek

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

typenoob avatar Apr 18 '23 08:04 typenoob

@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.

penghuili avatar Aug 10 '23 20:08 penghuili

@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.

agfe2silver avatar Aug 29 '23 06:08 agfe2silver

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

kasunprabath98 avatar Jul 09 '24 14:07 kasunprabath98

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

quangtuan28200 avatar Jul 18 '24 07:07 quangtuan28200

@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

GhayoorUlHaq avatar Jul 18 '24 16:07 GhayoorUlHaq

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 }

c-info avatar Aug 16 '24 05:08 c-info