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

[Yarn] Error When Installing Package: "command not found: patch-package" #573

Open
garygcchiu opened this issue Dec 7, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@garygcchiu
Copy link

Hey,

I've been trying to install this package into my Expo, React Native application using yarn3 for awhile now and keep running into this error when running yarn install:

➤ YN0000: ┌ Link step
➤ YN0007: │ @expensify/react-native-live-markdown@npm:0.1.199 [12bc8] must be built because it never has been before or the last one failed
➤ YN0009: │ @expensify/react-native-live-markdown@npm:0.1.199 [12bc8] couldn't be built successfully (exit code 127, logs can be found here: /private/var/folders/04/d5gndjrd4bg3wcd6d1n_h8vr0000gn/T/xfs-2097338f/build.log)
➤ YN0007: │ my-app@workspace:apps/expo must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 1s 379ms
➤ YN0000: Failed with errors in 3s 125ms

The error is:

# This file contains the result of Yarn building a package (@expensify/react-native-live-markdown@virtual:12bc83a8d977991f5f8523e8f1c7a17dd62498e860bf155e6cb3aecba6f13156324543dabc26866049dffa60c35571997e12ecfc029a5a1800346a514a3fad13#npm:0.1.199)
# Script name: postinstall

command not found: patch-package

I've tried:

  • Adding "patch-package": "^8.0.0", "postinstall-postinstall": "^2.1.0", to my package.json and then try re-installing. Still same error.
  • I am using a yarn monorepo, and have tried including both packages above into my root package.json, as well as my app/expo package.json. Still gives the error.

The version of react-native-live-markdown I have installed is 0.1.199.

Is there something else I should try?

@garygcchiu garygcchiu changed the title Error When Installing Package: "command not found: patch-package" [Yarn] Error When Installing Package: "command not found: patch-package" Dec 7, 2024
@garygcchiu
Copy link
Author

garygcchiu commented Dec 7, 2024

Created a quick error reproduction repo here: https://github.com/garygcchiu/react-native-live-markdown-yarn-error-repro

I am using yarn 3.4.1 in this case. I believe it may have something to do with how yarn2+ has native support for patching: https://www.npmjs.com/package/patch-package#yarn-v2

@garygcchiu
Copy link
Author

garygcchiu commented Dec 7, 2024

I was able to workaround this by creating a patch of my own to remove the postinstall:

yarn patch @expensify/react-native-live-markdown
  • Remove the postinstall script from the package.json
➜ yarn patch-commit -s /private/var/folders/...
yarn install

Resulting patch:

diff --git a/package.json b/package.json
index 38407d38b3172dbb6157a20cea9eb6cf960872f9..c4b435e291ac499580233a0ca206c37cbe93b470 100644
--- a/package.json
+++ b/package.json
@@ -37,8 +37,7 @@
     "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
     "prepare": "bob build",
     "build:watch": "nodemon --watch src --ext .ts,.tsx,.css --exec \"rm -f .build_complete && npm run prepare && npm pack && touch .build_complete\"",
-    "release": "release-it",
-    "postinstall": "patch-package"
+    "release": "release-it"
   },
   "keywords": [
     "react-native",

@tomekzaw
Copy link
Collaborator

tomekzaw commented Dec 8, 2024

@garygcchiu Thanks for reporting this issue. Someone from Live Markdown team will take a look at this shortly.

@tomekzaw tomekzaw added the bug Something isn't working label Dec 8, 2024
@nandorojo
Copy link
Contributor

Breaks on yarn 4 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants