Nothing Special   »   [go: up one dir, main page]

All Projects → frankhale → Electron With Express

frankhale / Electron With Express

Licence: mit
A simple app that demonstrates spawning an Express app from Electron

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Electron With Express

Wnr
⏱️ It's a time-management tool for computers. Work and rest, with wnr now.
Stars: ✭ 385 (-15.2%)
Mutual labels:  electron-application, electron-app
Mook
Markdown editor based on Electron and React
Stars: ✭ 117 (-74.23%)
Mutual labels:  electron-application, electron-app
Lepton
💻 Democratizing Snippet Management (macOS/Win/Linux)
Stars: ✭ 9,067 (+1897.14%)
Mutual labels:  electron-application, electron-app
Electron Tutorial App
An electron application for tutorials
Stars: ✭ 678 (+49.34%)
Mutual labels:  electron-application, electron-app
qikQR
minimal desktop app to create QR codes.
Stars: ✭ 20 (-95.59%)
Mutual labels:  electron-application, electron-app
Zy Player
▶️ 跨平台桌面端视频资源播放器.简洁无广告.免费高颜值. 🎞
Stars: ✭ 10,473 (+2206.83%)
Mutual labels:  electron-application, electron-app
Runjs
A JavaScript playground that auto-evaluates as you type
Stars: ✭ 1,266 (+178.85%)
Mutual labels:  electron-application, electron-app
Toby
A YouTube player for the desktop
Stars: ✭ 136 (-70.04%)
Mutual labels:  electron-application, electron-app
Vue Objccn
🔥 Use Vue.js to develop a cross-platform full stack application / 用 Vue.js 开发的跨三端应用
Stars: ✭ 1,993 (+338.99%)
Mutual labels:  electron-application, electron-app
Raven Reader
📖 All your articles in one place. Beautiful.
Stars: ✭ 2,040 (+349.34%)
Mutual labels:  electron-application, electron-app
Issues
Caret issues
Stars: ✭ 326 (-28.19%)
Mutual labels:  electron-application, electron-app
Electron Xiami
虾米音乐 & 虾米电台 - Linux & Mac | Xiami Player & Xiami Radio desktop for Linux & Mac supported by Electron
Stars: ✭ 304 (-33.04%)
Mutual labels:  electron-application, electron-app
Sieve
Sieve Script Editor
Stars: ✭ 452 (-0.44%)
Mutual labels:  electron-application, electron-app
Cmake Templates
Some CMake Templates (examples). Qt, Boost, OpenCV, C++11, etc 一些栗子
Stars: ✭ 368 (-18.94%)
Mutual labels:  example
Go Todo Rest Api Example
📚 A RESTful API example for simple todo application with Go
Stars: ✭ 385 (-15.2%)
Mutual labels:  example
Pygame tutorials
Code to go along with lessons at http://kidscancode.org/lessons
Stars: ✭ 363 (-20.04%)
Mutual labels:  example
React Redux Complete Example
A react+redux example project based on the folder structure proposed here: https://github.com/alexnm/re-ducks
Stars: ✭ 415 (-8.59%)
Mutual labels:  example
Keep
Desktop app for Google Keep packaged with Electron
Stars: ✭ 362 (-20.26%)
Mutual labels:  electron-app
Javascript Idiosyncrasies
A bunch of Javascript idiosyncrasies to beginners.
Stars: ✭ 353 (-22.25%)
Mutual labels:  example
Minta
✳️  Electron app for generating regular expressions
Stars: ✭ 353 (-22.25%)
Mutual labels:  electron-app

electron-with-express

A simple project demonstrating how to spawn an Express app from Electron as well as providing server logs directly in the Electron app.

Express App:

Express-App

Press Alt+CommandOrControl+L to show the server log:

Server-Log

Additional Information

The express-app folder is just a vanilla Express generated app using express-generator. Actually, this used to be the case but I moved the default routes from the routes folder to the root to make it a little easier to follow.

Dependencies

  • Node [https://nodejs.org/]

How to run

  1. Clone the code repository.
  2. Open terminal to code repository.
  3. Run npm install. (See Dependencies above)
  4. Change directories to the express-app folder and run npm install.
  5. Change directories back to the root of the code repository.
  6. Run npm start to start the application.

Package with Electron-Packager

If you would like to package this using electron-packager you'll need to make the following change:

In index.html (line ~65):

app = require("electron").remote.app),
node = spawn(".\\node_modules\\node\\bin\\node.exe", ["./express-app/bin/www"], {
  cwd: app.getAppPath()
});

This makes sure the path to our local copy of node.exe is correct when we run electron to start the app.

That said, I'm assuming the platform is Windows. If other platforms are desirable additional changes are required.

Package with Electron-Packager (ASAR)

In this scenario you will not need to have Node.exe and Node.lib like the README states. Using child_process.fork instead of child_process.spawn allows our code to work in exactly the same way but Electron will be used to spawn a new process for the Express server instead of our copy of Node.

In index.html around line 64 change the code to:

app = require("electron").remote.app),
node = require("child_process").fork(
    `${app.getAppPath()}/express-app/bin/www`,
    [],
    {
      stdio: ["pipe", "pipe", "pipe", "ipc"]
    };

You can then package the code up using the command line:

electron-packager . --overwrite --platform=win32 --arch=x64 --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Electron-With-Express\" --asar

Author(s)

Frank Hale <[email protected]>

Updated on: 16 January 2021

License

MIT - see LICENSE

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].