I have a web server written in Node.js and I would like to launch with a specific folder. I\'m not sure how to access arguments in JavaScript. I\'m running node like this:>
You can reach command line arguments using system.args
. And i use the solution below to parse arguments into an object, so i can get which one i want by name.
var system = require('system');
var args = {};
system.args.map(function(x){return x.split("=")})
.map(function(y){args[y[0]]=y[1]});
now you don't need to know the index of the argument. use it like args.whatever
Note: you should use named arguments like
file.js x=1 y=2
to use this solution.