Karl Morrison Karl Morrison - 1 year ago 144
Node.js Question

Accessing arguments sent via npm run-script

I run the command:

npm run a_script --oki="odo"

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

I tried:


It doesn't show up there.

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

Answer Source

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"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download