How to get startup arguments from Electron app?


I’m building a React app, and wrapping it in an Electron build. So far, I’m able to create a working, stand-alone build. Now, I want to add arguments to the launch:

open -a MyApp --args myName=One myVar=Two

As far as I understood, the process.argv gets extended with these arguments, but they don’t appear in the argument array.

Does anyone know how to get this fixed? I’ve searched the issues list and discussion board from Electron, Atom and StackOverflow, but nothing so far…



I don’t know how open passes the arguments across. Does it do that in the same way that a command from the terminal would? Are you trying to check the arguments in the main process? Or the renderer process?


Could it be that you are trying to access process.argv from the renderer process?
Use remote to get the arguments from main process instead:

const remote = require('electron').remote

after packaging i ran this terminal command:
open -a Electron\ tutorial\ --args myname=one
And i could see the argument myname


Hi all,

thanks for the feedback so far.
Could you, by any chance, provide a sample or something so that I can see what gets called when and where, please?

@crilleengvall, do you call your code from your embedded application?


@crilleengvall’s snippet would be from within your BrowserWindow (in other words, your React app). Otherwise you only have access to your process.argv from the Main process (the JS that’s run when you start the app that generates your browser windows)


I added the arguments to the electron quick start app.
This line is added to index.html (which runs in renderer process)
<p>Arguments <script>document.write(require('electron').remote.process.argv)</script>

Open up a terminal and run these commands to start the app

git clone
cd electron-quick-start/release-builds/Electron\ quick\ start-darwin-x64/
open -a Electron\ quick\ --args myname=one


I just got it working.
Thanks everyone!