-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node: --run requires an argument #53944
Comments
Reproductions:
|
If someone sends a PR to fix the docs, it will probably be accepted. |
What about the first example from @RedYetiDev's last comment? What's the expected behavior? Why is there a REPL being started? |
My reproductions were a bit out of order, but at the end of the issue, the author notes:
|
That doesn’t explain why the repl is started, though? I was surprised when that happened 😄 |
FWIW my assumption is that it treats an empty string as if the flag wasn't there, so it performs the action as if that flag wasn't applied, in this case, trigging the REPL. |
That's still quite odd and hardly seems desirable... I am wondering if it's intentional. @anonrig |
That's odd behaviour. This is valid JSON: {
"name": "nodejs_run_test",
"scripts": {
"hello": "echo hello",
"world": "echo world",
"": "echo !"
}
} i.e. it's valid to have an empty string as a JSON key. So I would expect FWIW as reference,
so Node.js could choose to do the same (but should probably be documented to do so, given that |
Since npm compatibility clearly wasn't a priority, I think it's reasonable for Node.js to implement some reasonable behavior instead. |
Agreed, I'm just not sure the current behaviour is reasonable 🙂. |
Affected URL(s)
https://nodejs.org/api/cli.html#--run
Description of the problem
The docs for
node --run
say:I thought that meant that if I run
node --run
, I’ll get a print of all available scripts (similar to hownpm run
works when not given a script name). But that results in an error:It’s still possible to get a listing of all available scripts, by passing a script name that does not exist:
I’m not sure what the exact problem is though:
node --run
should in fact print the available scripts?Thing I found while messing around with this that is probably out of scope in this issue:
Giving the empty string to
--run
does not try to execute{ "scripts": { "": "echo hi" } }
. Neither doesnpm run ''
though :)The text was updated successfully, but these errors were encountered: