1

I am trying to make a cli that uses flags as settings/options. It's all working, except it doesn't read the argvs. Here's what I'm doing now:

console.log(process.argv)
console.log(process.execArgv)

And here's what I get in the console:

C:\Users\divinelemon\Downloads\Programming\Node.js\client>npm start --output=file

> npm-generator@1.0.0 start C:\Users\divinelemon\Downloads\Programming\Node.js\client
> node index.js

[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\Users\\divinelemon\\Downloads\\Programming\\Node.js\\client\\index.js'
]
[]

As you can see, I clearly ran the script with the flag: --output=file but nothing shows up. Does this have something to do with the newest update of Node.js?

EDIT:

I used the link above and thought this was the best for my use case:

process.env.npm_config_<flag name>

Which can be used like this:

$ node index.js --foo=bar

This is what your index.js file would look like:

console.log(process.env.npm_config_foo)
//=> 'bar'
divinelemon
  • 1,925
  • 2
  • 23

0 Answers0