I just started using electron. I have a doubt about how to pass command line arguments in electron when I'm using npm start to run electron.
In Node.js I am using: node server.js one two=three four
command prompt for :
var arguments = process.argv.slice(2);
arguments.forEach(function(val,index, array) {
console.log(index + ': ' + val);
});
In Node.js is working. I need to know how can I make this work in electron.
Can someone please give a solution for this?
The way of passing arguments will be same, the only thing you have to take care is path of electron. In
package.jsonits writtennpmstart will performelectron main.js. So you will have to execute this command explicitly and pass arguments with "proper path of electron" i.e./node_modules/.bin/electron. Then the command will beand these arguments you can access by
process.argvinmain.jsand If wish you to access these parameters in your app then there are following things to do :
1.In your main.js define a variable like
2.In your app just include remote and use this
sharedObject3.Output will be
["argv1", "argv2"]