patch-package: Can't patch package

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
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

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 }

In case you find this issue:

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

Happy new year!

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.

@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

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.

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

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