2

I run the command:

npm run a_script --oki="odo"

How do I get the value of oki in my script? I'd like to use it for example: if(process.argv.oki === 'odo').

I tried:

console.log(process.argv);

It doesn't show up there.

I read https://docs.npmjs.com/cli/run-script and it doesn't give an example.

1 Answer 1

2

You just have to insert two dashes between the script name and the argument list for npm to pass them to your script.

e.g. npm run a_script -- --oki="odo"

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.