Self-contained React Native app possible?

660 Views Asked by At

I built a react-native app for Windows (https://github.com/Microsoft/react-native-windows). The app runs fine on my development machine, but if I copy the EXE (and DLL dependencies) to another machine and run, I get the error message

Unable to Download the JS bundle. Did you forget to start the development server or connect your device?

Is there a way to build a self-contained app that does not depend on a "development server"?

2

There are 2 best solutions below

0
On BEST ANSWER

React Native Windows Environment Setup (with Typescript)

  1. Download and Install Visual Studio 2017 Download Link
  2. Download and Install Visual Studio Code Download Link
  3. Download and Install NodeJS Download Link
  4. Install React Native CLI

    npm i -g react-native-cli

  5. Install TypeScript

    npm i -g typescript

  6. Create your project

    react-native init --version="0.55.0-rc.0" MyApp --template typescript && node MyApp/setup.js

  7. Change project directory MyApp

    cd MyApp

  8. Install the React Native Windows CLI Plugin

    npm i --save-dev rnpm-plugin-windows

  9. Run the Windows initialization command

    react-native windows --windowsVersion 0.55.0-rc.0

  10. Open project MyApp.sln file in Visual Studio

  11. Follow the prompts to install the Windows 10 SDK v. 10.0.14393.0

  12. If prompted, select Developer Mode in the Settings window under "Use developer features" and approve the Certificate Installation request. Enable "Developer mode" to allow the custom application to run

  13. Install windows build tools (run in Windows Power Shell)

    npm i -g --production windows-build-tools

  14. Run your application

    react-native run-windows

  15. Prompt Windows PowerShell Installing Certificate: Enter Y to install

  16. Prompt window: Allow Access to windows firewall

2
On

You can bundle your JS code using

react-native bundle --platform windows --entry-file index.windows.js
--bundle-output windows\myapp\ReactAssets\index.windows.bundle
--assets-dest windows\myapp\ReactAssets
--dev false

If you want to upload to store then you can follow https://learn.microsoft.com/en-us/windows/uwp/packaging/packaging-uwp-apps#create-an-app-package