This SO answer describes use of the process.argv
variable to access command line arguments when using node.js to run a javascript file。node.jsを使用してコマンドラインではなく.jsonファイルから引数にアクセスする方法は?
Here is the source documentation for process.argv
。
しかし、私の引数がコマンドラインで個別に入力するのではなく、.jsonファイルに格納されているとどうなりますか? node.jsを使ってそれらにアクセスする方法はありますか?
私はまた、自分のコンピュータ上でローカルに保存されている何とか私の.jsファイルへの引数としてdata.jsonロードしたいdata.json{
"foo": "bar",
"baz": "bat"
}
。その後、それを実行します。
app.jsvar foo = "bar",
baz = "bat"; // Somehow, I need to import these arguments from data.json
// Then do stuff with them...