Closed ORESoftware closed 7 years ago
This API is available since v0.7.7. What is the question, though?
@ORESoftware Do you mean the options listed in https://nodejs.org/api/cli.html + obtained with node --v8-options > v8.options.txt
?
@vsemozhetbyt @indutny I am looking to get them programmatically at runtime
I could spawn a child process to run node --v8-options
, but I am not certain if parsing the output will be that reliable, and I would rather avoid spawning a child process to accomplish this, if possible.
@ORESoftware What about parsing the output of node --help
and node --v8-options
?
@vsemozhetbyt thanks, that would work, but I am looking for a lighterweight way to do this.
I have a command line app, that's doing a lot of work already. I would rather not have to spawn a process and parse the output somehow.
There is no guarantee that the output format won't change. What I really need is an array in memory, like so:
const validNodeExecArgs = ['--foo','--bar','--baz'];
Unfortunately, it would be too unreliable to parse the output from node --v8-options
:
cc @nodejs/v8
thanks for the edit, much better, how did you do that? :)
I am hoping there might be some hidden data on process that is basically process.acceptableNodeExecArgs
, but maybe there isn't.
Node doesn't know what --v8-options
is going to print, that's handled by V8 itself. You have no choice but to parse it.
@bnoordhuis got it, thanks, good to know
@ORESoftware You can look in the code, just click the 'Edit comment' button :)
And you can save in the saved replies this code if you need (just delete \
before 3 backticks):
<details>
<summary>Label (click me):</summary>
```js
\```
</details><br>
@vsemozhetbyt nice thx
@bnoordhuis one more question for you, just out of curiosity, are all node.js execArgv options go towards V8? In other words, are V8 options and execArgv completely synonymous?
No, execArgv are basically the raw arguments up until the script name. E.g., if you pass --inspect
to node, that ends up in execArgv.
Might help you to know that the API is available as JSON for every version https://nodejs.org/api/cli.json - latest https://nodejs.org/dist/latest-v6.x/docs/api/cli.json - latest-v6.x
@refack thanks, good to know.
@bnoordhuis sorry that question wasn't very good, but you've answered it well enough thx
Is there an official list of Node.js exec args (process.execArgv) for each Node.js version?
I will look in user land, but curious what might be more official.