question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to pass additional arguments to Electron via electron-forge-start

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

This is less of a bug and more of a suggestion/improvement.

I am working on an Electron application that has two modes of operation (player and editor). By default the player is started unless the --editor flag is present on the CLI. In that case, the editor is launched.

I would definitely be useful to be able to pass CLI arguments to the Electron application via electron-forge start.

Currently, passing anything that is not a valid option for electron-forge-start will cause the command to halt on the fact it doesn’t understand the argument, meaning I have to either package my application to test the CLI flags or launch my application via node_modules/.bin/electron, which defeats the purpose of electron-forge start.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
onassarcommented, Feb 27, 2018

Any chance someone could show an example? I’m having trouble. Executing as follows: electron-forge start --- arg1value arg2value

Is this the correct format? If so, how can they be accessed in main.js? Trying with process.argv to no avail.

Electron version: 1.8.2

UPDATE: Ahh, just so #209. For anyone coming to this issue, it’s been updated to require two dashes: electron-forge start -- arg1value arg2value

They are indeed accessible via process.argv

Thanks team!

2reactions
lucapluscommented, Oct 28, 2021

did anyone try this method and did it work successfully? I tried to pass --- myArg and got errors like this:

$ yarn start --- --lang=fr
yarn run v1.12.3
$ electron-forge start --- --lang=fr
error: unknown option `---'
error Command failed with exit code 1.

Note that I used yarn to call electron-forge. electron-forge version:

└─ electron-forge@5.2.3

For future searches: you have to use the 2 dashes + 2 dashes for yarn

yarn start -- -- --lang=fr
Read more comments on GitHub >

github_iconTop Results From Across the Web

Ability to pass additional arguments to Electron via ... - GitHub
Currently, passing anything that is not a valid option for electron-forge-start will cause the command to halt on the fact it doesn't understand ......
Read more >
How to pass command line argument in electron
I just started using electron. I have a doubt about how to pass command line arguments in electron when I'm using npm start...
Read more >
A Comprehensive Guide to Building and Packaging an ...
Building and Packaging an Electron App wasn't as straight forward as I had hoped. This guide aims to help you navigate the complexities...
Read more >
Command Line Arguments in ElectronJS - GeeksforGeeks
We can pass Command-line arguments to Electron from outside the application on invoking it or we can simply hard code these values using...
Read more >
Electron in Action.pdf - Open Directory Data Archive
Your first Electron application 17 ... Persisting use data and using native Node.js modules 222 ... Additional features of the Electron shell module...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found