10

I wish to send some parameters when running a node script, using for instance

node myscript.js

from the terminal, so it can be read as below:

const fs = require('fs');

console.log(myParameter);
0

1 Answer 1

9

You just need to call as many arguments as you want, like:

node myscript.js arg1 arg2 arg3

And you recover them like:

console.log(process.argv[2]);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.