Skip to content

Instantly share code, notes, and snippets.

@rahsheen
Last active November 28, 2020 06:13
Show Gist options
  • Save rahsheen/4a540080fe0056954d770f28afff75c8 to your computer and use it in GitHub Desktop.
Save rahsheen/4a540080fe0056954d770f28afff75c8 to your computer and use it in GitHub Desktop.
NPM Script modifications for running React Native projects in WSL2.
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start --host 127.0.0.1",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"stop-winadb": "/mnt/c/Users/YOURNAME/AppData/Local/Android/Sdk/platform-tools/adb.exe kill-server",
"start-winadb": "/mnt/c/Users/YOURNAME/AppData/Local/Android/Sdk/platform-tools/adb.exe -a nodaemon server start",
"winadb": "yarn stop-winadb && yarn start-winadb",
"socat": "socat -d -d TCP-LISTEN:5037,reuseaddr,fork TCP:$(ip route|grep default|cut -d ' ' -f3):5037",
"emulator": "/mnt/c/Users/YOURNAME/AppData/Local/Android/Sdk/emulator/emulator.exe @Pixel_3_API_28"
}
@rahsheen
Copy link
Author

rahsheen commented Nov 28, 2020

Gist based on info from here and other places.

Normal usage would be something like:

yarn start
yarn emulator
yarn winadb
yarn socat
yarn android

There's likely a fancy scripty way to run all of these commands in order, but I didn't have the time to figure that out. I just run them all in separate terminal tabs.

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