Karl Morrison Karl Morrison - 5 months ago 44
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.


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"