====== eject ====== [[https://medium.com/reactbrasil/being-free-from-expo-in-react-native-apps-310034a3729|Being free from “expo” in React Native apps]] ====== eject ====== >npm run eject > @ eject C:\Users\Ryu\react\expo-backgroundTimer > expo eject We didn't find any uses of the Expo SDK in your project, so you should be fine to eject to "Plain" React Native. (This check isn't very sophisticated, though.) Warning! Your git working tree is dirty. It's recommended to commit all your changes before proceeding, so you can revert the changes made by this command if necessary. ? How would you like to eject your app? Read more: https://docs.expo.io/versions/latest/expokit/eject/ React Native We have a couple of questions to ask you about how you'd like to name your app: ? What should your app appear as on a user's home screen? backgroundTimer ? What should your Android Studio and Xcode projects be called? backgroundTimer Writing app.json... Wrote to app.json, please update it manually in the future. Generating the iOS folder. Generating the Android folder. Successfully copied template native code. Updating your npm scripts in package.json... Your package.json is up to date! Note that using `npm start` will now require you to run Xcode and/or Android Studio to build the native code for your project. Removing node_modules... Installing existing packages with npm... npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) Ejected successfully! ===== npm g react-native-cli ===== 通常のreact nativeコマンドを使えるようにする。 >npm g react-native-cli undefined C:\Users\Ryu\react\expo-backgroundTimer>npm install -g react-native-cli C:\Program Files (x86)\Nodist\bin\react-native -> C:\Program Files (x86)\Nodist\bin\node_modules\react-native-cli\index.js + react-native-cli@2.0.1 updated 3 packages in 1.3s ===== React Native CLIコマンド ===== npm install -g react-native-cli # cliをインストールしてから以下のコマンドを使用する react-native init アプリ名 #新規アプリを作成 react-native run-ios #iOSで起動します react-native run-android #Androidで起動します react-native link #ネイティブコードとのリンクを行う(パッケージをインストールするときによく使う) ===== Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault' ===== react-native linkを実行しようとするとエラーが発生する。 >react-native link internal/modules/cjs/loader.js:605 throw err; ^ Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15) at Function.Module._load (internal/modules/cjs/loader.js:529:25) at Module.require (internal/modules/cjs/loader.js:658:17) at require (internal/modules/cjs/helpers.js:22:18) at Object. (C:\Users\Ryu\react\expo-backgroundTimer\node_modules\react-native\local-cli\cliEntry.js:11:41) at Module._compile (internal/modules/cjs/loader.js:722:30) at Module._compile (C:\Users\Ryu\react\expo-backgroundTimer\node_modules\pirates\lib\index.js:99:24) at Module._extensions..js (internal/modules/cjs/loader.js:733:10) at Object.newLoader [as .js] (C:\Users\Ryu\react\expo-backgroundTimer\node_modules\pirates\lib\index.js:104:7) at Module.load (internal/modules/cjs/loader.js:620:32) react-native run-android internal/modules/cjs/loader.js:605 throw err; ^ Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15) at Function.Module._load (internal/modules/cjs/loader.js:529:25) at Module.require (internal/modules/cjs/loader.js:658:17) at require (internal/modules/cjs/helpers.js:22:18) at Object. (C:\Users\Ryu\react\expo-backgroundTimer\node_modules\react-native\local-cli\cliEntry.js:11:41) at Module._compile (internal/modules/cjs/loader.js:722:30) at Module._compile (C:\Users\Ryu\react\expo-backgroundTimer\node_modules\pirates\lib\index.js:99:24) at Module._extensions..js (internal/modules/cjs/loader.js:733:10) at Object.newLoader [as .js] (C:\Users\Ryu\react\expo-backgroundTimer\node_modules\pirates\lib\index.js:104:7) at Module.load (internal/modules/cjs/loader.js:620:32) npm add @babel/runtime を実行するとなおった。 ===== react-native run-androidのエラー ===== [[https://qiita.com/n0bisuke/items/2c02f7a1be956440e72e|React NativeのAndroid実機ビルドと出たエラー対処メモ #rnjapan]] >react-native run-android Could not find the "expo" package in your project when configuring the packager JS server already running. Building and installing the app on the device (cd android && gradlew.bat installDebug)... FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':app'. > SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 1s Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/getting-started.html 環境変数にANDROID_HOMEにC:\Users\ユーザー名\AppData\Local\Android\sdkを追加する。 環境変数変更後はプロンプトやvscodeの再起動が必要。 ===== Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_201 contains a valid JDK installation ===== システム環境変数にJAVA_HOMEにC:\Program Files\Java\jre1.8.0_201を追加する。 下記コマンドで設定を確認 >echo %JAVA_HOME% C:\Program Files\Java\jre1.8.0_201