almost 9 years ago
Hi All,
While working on one of my project we had a requirement where we need to run our web application as a desktop application and to do that we found a solution called Electron which can w=be used as an installer and it run on various plate forms like MAC, Windows and Linux.
Now what is Electron and how we can use it to create an installer to run our app as a desktop application on various platform?
Electron is a tool which come with built-in io.js and Chromium which is built on V8 JavaScript Engine which is an open source JavaScript engine developed by The Chromium Project for the Google Chrome web browser.
Electron relies on the Squirrel framework and It takes care of creating the actual package, signing it, dealing with updates, and many more things.
So the first this you need to have to get started is to install the Electron Packager and to do that you need to open the cmd/terminal (in case of mac) and run the command :
Bellow is the code for the sample app that you can go ahead and create :
in Index.html we have :
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chromium <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chromium <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</body>
</html>
In the package.json we have :
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron main.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/electron/electron-quick-start.git"
},
"keywords": [
"Electron",
"quick",
"start",
"tutorial"
],
"author": "GitHub",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/electron/electron-quick-start/issues"
},
"homepage": "https://github.com/electron/electron-quick-start#readme",
"devDependencies": {
"electron-prebuilt": "^0.37.0"
}
}
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron main.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/electron/electron-quick-start.git"
},
"keywords": [
"Electron",
"quick",
"start",
"tutorial"
],
"author": "GitHub",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/electron/electron-quick-start/issues"
},
"homepage": "https://github.com/electron/electron-quick-start#readme",
"devDependencies": {
"electron-prebuilt": "^0.37.0"
}
}
and to run this we need to navigate to electron-quick-start folder and then run command
and than to run the app, you need to run the command
Can you help out the community by solving one of the following Javascript problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)