'How to install electron offline without github
I try to install electron offline. I mean without github and internet access. I have jfrog artifactory for the electron package but the installation requires also binary data. So i downloaded the zip file with the binary data and put it in the offline computer. The zip file: electron-v12.0.0-win32-x64.zip
I follow the instructions in:
https://www.electronjs.org/docs/tutorial/installation
But its very unclear!
I dont have any site to mirror the zip, is there any other way to mirror from the computer and not from some sites?
The second option is to put the zip in Cache file, but it requires a hash file. How do i generate it?
What is the simplest way to install electron with downloaded zip?
Thanks in advance.
Solution 1:[1]
So to install electron offline, i recommend to do the following steps:
In computer with internet execute the command:
npm i electron
This will cache the electron.zip in your computer. In my windows pc its located in:
C: \Users\baruch\AppData\Local\electron\Cache\some string
So copy to your offline pc all the electron\Cache directory. Everything there is important the Shasum256. txt etc
Now in the offline pc, when you try to execute npm i electron. It will go first to the cache. (You can check it without copy to offline pc, by simply turn your internet access to flight mode and see it will go to cache)
But the real solution need to be with mirroring. Example for electron vesrion 13.1.2:
Go to github and download SHASUM256.txt and electron-v13.1.2-win32-x64.zip.
In jfrog artifactory create a "generic repository" for ex' called sandbox. Inside sandbox create folder called electron, and inside electron create folder called v13.1.2.
Put the SHASUM256.txt and the zip file inside v13.1.2 folder.
Go to your project and create file called .npmrc and write there:
ELECTRON_MIRROR="http://artifacteoy site/sandbox/electron/
Be aware for the slash at the end.
Now type npm i electron, and it will download it. Thats all.
Solution 2:[2]
I will answer your first question.
Even though you don't have a mirror site that does not mean that you cannot serve the file: electron-v12.0.0-win32-x64.zip
.
What I ended up quickly doing is just to serve the file from localhost, by running a simple temporary http server using http-server
. You can find it here: https://www.npmjs.com/package/http-server . You could use any http server you have access to, to serve localhost such nginx, apache2, or just node.js using the http package as described here: https://www.w3schools.com/nodejs/nodejs_http.asp
The http server should be running during the (post) installation of electron.
let's say you are using http-server
. Now you need to make sure the file is in the correct folder, and you need to set the environment variables as described in https://www.electronjs.org/docs/latest/tutorial/installation
export ELECTRON_MIRROR=localhost:8080
export ELECTRON_CUSTOM_DIR=v12.0.0
export ELECTRON_CUSTOM_FILENAME=electron-v12.0.0-win32-x64.zip
the file should be in the folder v12.0.0. For example:
/var/www/v12.0.0/electron-v12.0.0-win32-x64.zip
and then you can start the server with:
$ http-server /var/www
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Baruch Levin |
Solution 2 | Ouss |