{"id":13941888,"url":"https://github.com/lawalter/r-shiny-electron-app","last_synced_at":"2025-07-20T05:31:17.839Z","repository":{"id":188356028,"uuid":"241430021","full_name":"lawalter/r-shiny-electron-app","owner":"lawalter","description":":memo: Guide to desktop app creation using R Shiny and Electron","archived":true,"fork":false,"pushed_at":"2020-03-18T16:53:14.000Z","size":590,"stargazers_count":39,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-27T11:37:20.603Z","etag":null,"topics":["electron","electron-forge","r","r-shiny","r-shiny-electron","shiny"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lawalter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-02-18T17:56:56.000Z","updated_at":"2024-08-08T10:45:59.000Z","dependencies_parsed_at":"2023-08-15T01:22:08.196Z","dependency_job_id":null,"html_url":"https://github.com/lawalter/r-shiny-electron-app","commit_stats":null,"previous_names":["lawalter/r-shiny-electron-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lawalter/r-shiny-electron-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lawalter%2Fr-shiny-electron-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lawalter%2Fr-shiny-electron-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lawalter%2Fr-shiny-electron-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lawalter%2Fr-shiny-electron-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lawalter","download_url":"https://codeload.github.com/lawalter/r-shiny-electron-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lawalter%2Fr-shiny-electron-app/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266071519,"owners_count":23871940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","electron-forge","r","r-shiny","r-shiny-electron","shiny"],"created_at":"2024-08-08T02:01:34.065Z","updated_at":"2025-07-20T05:31:15.301Z","avatar_url":"https://github.com/lawalter.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# How to Make an R Shiny Electron App \n\nA setup guide by L. Abigail Walter\n\u003cbr\u003eInstructions adapted from \u003ca href=\"https://www.travishinkelman.com/post/deploy-shiny-electron/\"\u003eTravis Hinkelman\u003c/a\u003e \n\u003cbr\u003eR Shiny Electron template created by \u003ca href=\"https://github.com/dirkschumacher/r-shiny-electron\"\u003eDirk Shumacher\u003c/a\u003e\n\n### Introduction\n\n\u003cb\u003eMotivation:\u003c/b\u003e In February 2020, I was unable to create a standalone desktop app using an R Shiny Electron template via Dirk Shumaker's \u003ca href=\"https://github.com/dirkschumacher/r-shiny-electron\"\u003eoriginal repo\u003c/a\u003e or Travis Hinkelman's \u003ca href=\"https://github.com/hinkelman/r-shiny-electron\"\u003efork\u003c/a\u003e. I avoided the warnings created with their methods by using npx instead of npm, and by adding file index.js that redirects, and wanted to share this information with other users.\n\n\u003cb\u003eObjective:\u003c/b\u003e Write a comprehensive guide for anyone interested in creating an R Shiny Electron app. This guide assumes the user has intermediate R coding skills, intermediate ability to use the terminal, and little to no experience with JavaScript. \n\n\u003cb\u003eAcknowledgements:\u003c/b\u003e I credit \u003ca href=\"https://github.com/dirkschumacher/r-shiny-electron\"\u003eDirk Shumacher\u003c/a\u003e for writing most scripts in this repo, only some of which I edited with only minor changes. In addition, \u003ca href=\"https://www.travishinkelman.com/post/deploy-shiny-electron/\"\u003eTravis Hinkelman\u003c/a\u003e created the groundwork for this guide, which I made changes to in order to avoid warnings and reports of vulnerabilities and to ultimately allow the app to launch.\n\n\u003cb\u003eNote:\u003c/b\u003e I recommend building your app using macOS if possible; it is _much_ simpler than Windows. \n\n### Navigation\n\n- [Setup guide: macOS](#getting-started-on-macos) - complete!\n- [Setup guide: Windows](#getting-started-on-windows) - complete!\n- [Setup guide: Linux](#getting-started-on-linux) - in progress\n- [Troubleshooting](#troubleshooting)\n\n---\n\n## Getting started on macOS\nAll of the following steps can be run exclusively in the RStudio terminal\n\n### Steps to get your computer ready:\n\n1. Install Node.js: https://nodejs.org/en/\n2. Install Electron Forge using npm (npm is installed with Node.js)\n    - In the R terminal, run `npm i -g @electron-forge/cli` \n    - If there's a permission error, run `sudo npm i -g @electron-forge/cli`\n3. Check your versions of node `node -v` and npm `npm -v`. For this guide, I will be using \u003cb\u003enode v13.9.0\u003c/b\u003e and \u003cb\u003enpm v6.13.7\u003c/b\u003e. If your installations do not match mine and you experience problems with these steps, try downgrading or upgrading (see [Troubleshooting](#troubleshooting) section below).\n4. Open an existing R project, create a new one, or initialize a project by cloning a git repo.\n  \n## Advanced macOS steps\n  \n### Start here if you have all of the dependencies installed:\n\n5. Make sure your directory is in R project folder you're ready to turn into an app. \n    - Run ```pwd``` on the command line to check what directory you are in. \n    - If you're not in the right folder, change your directory using `cd example/file/path` with the example path replaced with the appropriate path to your project. \n6. In your project directory, install Electron locally by running `npx create-electron-app appNameHere`. Replace appNameHere with whatever you want to name your app. \n    - \u003cb\u003eNote:\u003c/b\u003e Your app cannot be titled \"app\".\n7. In your appNameHere folder, delete folder \u003cb\u003esrc\u003c/b\u003e. \n8. Move files (I typically use the R file pane gui) to your new app folder, including:\n- get-r-mac.sh \n- add-cran-binary-pkgs.R\n- start-shiny.R\n- Folder \u003cb\u003eshiny\u003c/b\u003e from this repo, containing: \n    - shiny/app.R \n- Folder \u003cb\u003esrc\u003c/b\u003e from this repo, containing:\n    - src/failed.html\n    - src/helpers.js\n    - src/index.css\n    - src/index.js\n    - src/loading.css\n    - src/loading.html\n    - src/main.js\n- \u003cb\u003eNote:\u003c/b\u003e File app.R is whatever R Shiny script you want to launch in your application. You can use the example provided in this repo or use your own.\n9. Change your directory to your new app folder `cd appNameHere`\n10. Install R locally:\n    - First, check the version of R on your machine. In the R console, run `version` \n    - Edit get-r-mac.sh, replacing version numbers in the link `https://cloud.r-project.org/bin/macosx/R-3.6.2.pkg` with the version you are running. \n        - \u003cb\u003eImportant:\u003c/b\u003e The R version used to make the shiny app and the version installed locally must match. The app included in this repo was created in R v3.6.2.\n    - Once you save the file, run the shell script in the terminal `sh ./get-r-mac.sh` \n11. If you don't have the automagic package installed, run `install.packages(\"automagic\")` in the R console. \n12. In the R terminal, run `Rscript add-cran-binary-pkgs.R` to get packages for R. \n13. Add additional dependencies to package.json. Replace the dependencies listed at the end of the script with the following. Take care not to paste over the final ending bracket `}` of the .json file.\n```js      \n    \"dependencies\": {\n      \"axios\": \"^0.19.2\",\n      \"electron-squirrel-startup\": \"^1.0.0\",\n      \"esm\": \"^3.2.25\",\n      \"execa\": \"^4.0.0\"\n    },\n    \"devDependencies\": {\n      \"@babel/core\": \"^7.8.4\",\n      \"@babel/plugin-transform-async-to-generator\": \"^7.8.3\",\n      \"@babel/preset-env\": \"^7.8.4\",\n      \"@babel/preset-react\": \"^7.8.3\",\n      \"@electron-forge/cli\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-deb\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-rpm\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-squirrel\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-zip\": \"^6.0.0-beta.50\",\n      \"electron\": \"8.0.2\",\n      \"eslint\": \"^6.8.0\",\n      \"eslint-config-airbnb\": \"^18.0.1\",\n      \"eslint-plugin-import\": \"^2.20.1\",\n      \"eslint-plugin-jsx-a11y\": \"^6.2.3\",\n      \"eslint-plugin-react\": \"^7.18.3\",\n      \"eslint-plugin-react-hooks\": \"^1.7.0\",\n      \"fs-extra\": \"^8.1.0\"\n      }\n```\n\u003cb\u003eNote:\u003c/b\u003e Modules are updated frequently and as such are subject to changing version numbers. It is important to double-check that these dependencies are up-to-date by replacing their version numbers with any newer version numbers. You can accomplish this by manually searching the module names at https://www.npmjs.com/\n\n\u003cb\u003eNote:\u003c/b\u003e We are using `\"eslint-plugin-react-hooks\": \"^1.7.0\"` because using the latest v2.4.0 throws a warning.\n\n\u003cb\u003eOptional\u003c/b\u003e: If you have not added a field in the package.json for repository information, you will see a warning when running `npm install`. This is not a serious warning, but it is good practice to edit the .json with your git repo if you have the time. To do this, insert the following to your package.json:\n```js\n \"repository\": {\n  \"type\": \"git\",\n  \"url\": \"git://github.com/username/repo.git\"\n  },\n```\n\n14. Replace the `\"lint\": \"echo \\\"No linting configured\\\"\"` line in package.json with `\"lint\": \"eslint src --color\"`\n15. Run `npm install` to add new dependencies you listed in package.json to the node_modules folder.\n16. Test to see if your app works by running `electron-forge start`\n17. If the app runs successfully, congratulations! Package and create the .exe on the command line with `electron-forge make`. Your app can be found in the /out folder.\n\n---\n\n## Getting started on Windows\nUnlike the macOS setup, Windows will require the use of multiple terminals, which are specified at each step\n\n### Steps to get your computer ready:\n\n1. Install Node.js: https://nodejs.org/en/\n    - Check the box option during the node.js install to also install chocolatey\n2. Skip this step if chocolatey is installed. If chocolatey has \u003cb\u003enot\u003c/b\u003e been installed:\n    - Open Windows PowerShell with right-click option \"Run as Administrator\" \n    - Follow the installation steps on the \u003ca href=\"https://chocolatey.org/install\"\u003echocolatey\u003c/a\u003e website\n3. Using chocolatey, install innoextract v1.8 or greater:\n    - Re-open Windows PowerShell with right-click option \"Run as Administrator\" \n        - \u003cb\u003eNote:\u003c/b\u003e If you just installed chocolatey in Windows PowerShell, you need to close and re-launch the admin shell\n    - Run `choco install innoextract` \n        - If innoextract is already installed at a version less than v1.8, run ```choco upgrade innoextract```\n4. In the same Administrator Windows PowerShell, install Electron Forge globally\n    - Run `npm install -g electron-forge`\n5. Install \u003ca href=\"https://cygwin.com/\"\u003eCygwin\u003c/a\u003e\n    - During Cygwin install, \u003ca href=\"https://superuser.com/questions/693284/wget-command-not-working-in-cygwin\"\u003eselect wget packages\u003c/a\u003e at the 'packages' screen by clicking the arrow in the 'new' clolumn to select the newest version.\n6. Check your versions of node `node -v` and npm `npm -v` using any terminal. For this guide, I will be running \u003cb\u003enode v13.9.0\u003c/b\u003e and \u003cb\u003enpm v6.13.7\u003c/b\u003e. If your installations do not match mine and you experience problems with these steps, try downgrading or upgrading (see [Troubleshooting](#troubleshooting) section below).\n7. Open an existing R project, create a new one, or initialize a project by cloning a git repo.\n  \n## Advanced Windows steps\n  \n### Start here if you have all of the dependencies installed:\n\n8. Make sure your directory is in R project folder you're ready to turn into an app. \n    - In Windows PowerShell, run `pwd` on the command line to check what directory you are in. \n    - If you're not in the right folder, change your directory using `cd C:\\Users\\Name\\Desktop\\gitFolderName` with the example path replaced with the appropriate path to your project. \n9. In your project directory, install Electron locally:\n    - Using Windows PowerShell, run `npx create-electron-app appNameHere`\n    - Replace appNameHere with whatever you want to name your app. \n        - \u003cb\u003eNote:\u003c/b\u003e Your app cannot be titled \"app\".\n10. In your appNameHere folder, delete folder \u003cb\u003esrc\u003c/b\u003e. \n11. Move files (I typically use the R file pane gui) to your new app folder, including:\n- get-r-win.sh\n- add-cran-binary-pkgs.R\n- start-shiny.R\n- Folder \u003cb\u003eshiny\u003c/b\u003e from this repo, containing:  \n    - shiny/app.R \n- Folder \u003cb\u003esrc\u003c/b\u003e from this repo, containing:\n    - src/failed.html\n    - src/helpers.js\n    - src/index.css\n    - src/index.js\n    - src/loading.css\n    - src/loading.html\n    - src/main.js\n12. In Windows PowerShell, change your directory to your new app folder `cd appNameHere`\n13. Install R locally:\n    - First, check the version of R on your machine. In the R console, run `version`\n    - Edit get-r-win.sh, replacing version numbers in the link `https://cloud.r-project.org/bin/windows/base/R-3.6.2-win.exe` with the version you are running if you made the app.R, or the version of R that was used to make the app.\n        - \u003cb\u003eImportant:\u003c/b\u003e The R version used to make the shiny app and the version installed locally must match. The app included in this repo was created in R v3.6.2.\n    - Open the Cygwin terminal. Change your directory by 1) typing `cd`, 2) opening File Explorer and navigating to your app folder, then 3 ) dragging the app folder itself to the Cygwin terminal window to paste the file path. Run the command.\n        - \u003cb\u003eExample:\u003c/b\u003e `cd /cygdrive/c/Users/Abby/Desktop/git/r-shiny-electron-app/appNameHere`\n    - In Cygwin, run `sh ./get-r-win.sh`\n        - \u003cb\u003eIf you got an error:\u003c/b\u003e you will likely need to convert get-r-win.sh to Unix \n        - To fix error `./get-r-win.sh: line 5 --output-document: command not found`\n            - Download \u003ca href=\"https://notepad-plus-plus.org/\"\u003eNotepad++\u003c/a\u003e if you don't already have it\n            - Open get-r-win.sh in Notepad++\n            - Go to Edit -\u003e EOL Conversion -\u003e Unix (LF)\n            - Save the script\n            - In Cygwin, re-run `sh ./get-r-win.sh` \n14. In the R console, `install.packages(\"automagic\")` if this package is not already installed.\n15. Switch to the RStudio terminal and make sure your directory is in the appNameHere folder. Get packages for R by running ```Rscript add-cran-binary-pkgs.R```\n16. Using R, edit package.json to add additional dependencies. Replace the dependencies listed at the end of the script with the following. Take care not to paste over the final ending bracket `}` of the .json file.\n```js      \n    \"dependencies\": {\n      \"axios\": \"^0.19.2\",\n      \"electron-squirrel-startup\": \"^1.0.0\",\n      \"esm\": \"^3.2.25\",\n      \"execa\": \"^4.0.0\"\n    },\n    \"devDependencies\": {\n      \"@babel/core\": \"^7.8.4\",\n      \"@babel/plugin-transform-async-to-generator\": \"^7.8.3\",\n      \"@babel/preset-env\": \"^7.8.4\",\n      \"@babel/preset-react\": \"^7.8.3\",\n      \"@electron-forge/cli\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-deb\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-rpm\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-squirrel\": \"^6.0.0-beta.50\",\n      \"@electron-forge/maker-zip\": \"^6.0.0-beta.50\",\n      \"electron\": \"8.0.2\",\n      \"eslint\": \"^6.8.0\",\n      \"eslint-config-airbnb\": \"^18.0.1\",\n      \"eslint-plugin-import\": \"^2.20.1\",\n      \"eslint-plugin-jsx-a11y\": \"^6.2.3\",\n      \"eslint-plugin-react\": \"^7.18.3\",\n      \"eslint-plugin-react-hooks\": \"^1.7.0\",\n      \"fs-extra\": \"^8.1.0\"\n      }\n```\n\u003cb\u003eNote:\u003c/b\u003e Modules are updated frequently and as such are subject to changing version numbers. It is important to double-check that these dependencies are up-to-date by replacing their version numbers with any newer version numbers by manually searching the module names at https://www.npmjs.com/\n\n\u003cb\u003eNote:\u003c/b\u003e We are using `\"eslint-plugin-react-hooks\": \"^1.7.0\"` because using the latest v2.4.0 throws a warning.\n\n\u003cb\u003eOptional\u003c/b\u003e: If you have not added a field in the package.json for repository information, you will see a warning when running `npm install`. This is not a serious warning, but it is good practice to edit the .json with your git repo if you have the time. To do this, insert the following to your package.json:\n```js\n \"repository\": {\n  \"type\": \"git\",\n  \"url\": \"git://github.com/username/repo.git\"\n  },\n```\n\n17. Replace the `\"lint\": \"echo \\\"No linting configured\\\"\"` line in package.json with `\"lint\": \"eslint src --color\"`\n18. In Cygwin, run `npm install` to add new dependencies you listed in package.json to the node_modules folder.\n19. Test to see if your app works by running `electron-forge start` in the Cygwin terminal.\n    - To stop running the app, press `Ctrl+C`\n20. If the app runs successfully, congratulations! Package and create the .exe on the command line with `electron-forge make`. Your app can be found in the /out folder.\n\n---\n\n## Getting started on Linux\nThese steps were created on and for Linux Mint 18, but should work with any Ubuntu edition\n\n### Steps to get your computer ready:\n\n1. Install Node.js using the terminal `sudo apt install nodejs-legacy`\n2. Your Node.js version is probably behind, so next install a version manager `sudo npm install -g n`\n    - Upgrade Node.js \n        - To the most recent version, which at present is v13.9.0, by running `sudo n 13.9.0`\n        - Or to the most recent stable version using `sudo n stable`\n3. Install Electron Forge\n    - Run `npm i -g @electron-forge/cli`\n    - If there's a permission error, run `sudo npm i -g @electron-forge/cli`\n4. Check your versions of node `node -v` and npm `npm -v`. For this guide, I will be using \u003cb\u003enode v13.9.0\u003c/b\u003e and \u003cb\u003enpm v6.13.7\u003c/b\u003e. If your installations do not match mine and you experience problems with these steps, try downgrading or upgrading (see [Troubleshooting](#troubleshooting) section below).\n5. Open an existing R project, create a new one, or initialize a project by cloning a git repo.\n  \n## Advanced Linux steps\n  \n### Start here if you have all of the dependencies installed:\n\n6. Make sure your directory is in R project folder you're ready to turn into an app. \n    - Run `pwd` on the command line to check what directory you are in. \n    - If you're not in the right folder, change your directory using `cd example/file/path` with the example path replaced with the appropriate path to your project. \n7. In your project directory, install Electron locally by running `npx create-electron-app appNameHere`. Replace appNameHere with whatever you want to name your app. \n    - \u003cb\u003eNote:\u003c/b\u003e Your app cannot be titled \"app\".\n8. In your appNameHere folder, delete folder \u003cb\u003esrc\u003c/b\u003e. \n9. Move files (I typically use the R file pane gui) to your new app folder, including:\n- get-r-linux.sh -- shell script adapted from \u003ca href=\"https://docs.rstudio.com/resources/install-r-source/\"\u003eRStudio Documentation\u003c/a\u003e by me\n- add-cran-binary-pkgs.R\n- start-shiny.R\n- Folder \u003cb\u003eshiny\u003c/b\u003e from this repo, containing:  \n    - shiny/app.R \n- Folder \u003cb\u003esrc\u003c/b\u003e from this repo, containing:\n    - src/failed.html\n    - src/helpers.js\n    - src/index.css\n    - src/index.js\n    - src/loading.css\n    - src/loading.html\n    - src/main.js\n- \u003cb\u003eNote:\u003c/b\u003e File app.R is whatever R Shiny script you want to launch in your application. You can use the example provided in this repo or use your own.\n10. Change your directory to your new app folder `cd appNameHere`\n11. Install R locally:\n    - First, check the version of R on your machine. In the R console, run `version`\n    - Open get-r-linux.sh and edit the line `export R_VERSION=3.6.2` with the version you are running if you made the app.R, or the version of R that was used to make the app.\n        - \u003cb\u003eImportant:\u003c/b\u003e The R version used to make the shiny app and the version installed locally must match. The app included in this repo was created in R v3.6.2.\n        - \u003cb\u003eNote:\u003c/b\u003e I only cover installing R locally on Ubuntu and Ubuntu-based editions. To install R locally on another Linux distribution, cheeck out the \u003ca href=\"https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Installing-R-under-Unix_002dalikes\"\u003eR Installation and Administration Manual\u003c/a\u003e and readme files in the \u003ca href=\"https://cloud.r-project.org/bin/linux/ubuntu/\"\u003eR directories\u003c/a\u003e. Good luck!\n    - Save your edit(s) in get-r-linux.sh and then run the shell script in the terminal `sh ./get-r-linux.sh` \n        - \u003cb\u003eNote:\u003c/b\u003e This step may take a while (5-15 mins).\n\n*To be continued -- local R install still not 100%*\n\n---\n\n## Troubleshooting \nSteps for macOS, Windows, and Linux\n\n- To change your version of Node.js, install \u003cb\u003en\u003c/b\u003e with npm. This module will enable you downgrade or upgrade Node.js if there is an issue running it at your current version. In the terminal, run `sudo npm install -g n` to install.\n    - \u003cb\u003eExample:\u003c/b\u003e To change to Node v10.16.3 run `sudo n 13.9.0`\n\n[Back to top](#how-to-make-an-r-shiny-electron-app)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flawalter%2Fr-shiny-electron-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flawalter%2Fr-shiny-electron-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flawalter%2Fr-shiny-electron-app/lists"}