React Native – How to fix node_modules?

Use patch-package
easier-react-native-upgrade-with-patch-package
say-goodbye-to-old-fashioned-forks-thanks-to-the-patch-package

Setup

  • Install package
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
yarn add patch-package postinstall-postinstall
yarn add patch-package postinstall-postinstall
yarn add patch-package postinstall-postinstall
  • Edit package.json > scripts
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"scripts": {
"postinstall": "patch-package"
}
"scripts": { "postinstall": "patch-package" }
 "scripts": {
   "postinstall": "patch-package"
 }

Create patch

  • Fix & save file in node_modules
  • Create patch, a patches directory will be created
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
yarn run patch-package react-native-material-menu
yarn run patch-package react-native-material-menu
yarn run patch-package react-native-material-menu
  • From now on it will automatically patch the module when you install dependencies
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
> yarn
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ patch-package
patch-package: Applying patches...
react-native-material-menu ✔
> yarn yarn install v0.27.5 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... $ patch-package patch-package: Applying patches... react-native-material-menu ✔
> yarn
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ patch-package
patch-package: Applying patches...
react-native-material-menu ✔

Be the first to comment

Leave a Reply

Your email address will not be published.


*