0

I would like to run my node script and pass a parameter to this node script

for example my node script index.js looks like :

var user = "me";
console.log(user);

and I would like the user to be a parameter instead of using

node index.js

I can use node index.js --user foo and the parameter pass to the script

Do you have any idea what I should use

1

1 Answer 1

1

It seems as though you are trying to pass command line arguments in Node. Check out this for multiple explanations on how to do that: How do I pass command line arguments? Seems like this would do if you only have one argument:

var user = process.args.slice(2)
console.log(user);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.