Skip to content

node: --run requires an argument #53944

@lydell

Description

@lydell

Affected URL(s)

https://nodejs.org/api/cli.html#--run

Description of the problem

The docs for node --run say:

If no "command" is provided, it will list the available scripts.

I thought that meant that if I run node --run, I’ll get a print of all available scripts (similar to how npm run works when not given a script name). But that results in an error:

❯ node --version
v22.5.0
❯ node --run
node: --run requires an argument

It’s still possible to get a listing of all available scripts, by passing a script name that does not exist:

❯ node --run .
ExperimentalWarning: Task runner is an experimental feature and might change at any time

Missing script: "."

Available scripts are:
  test: whatever

I’m not sure what the exact problem is though:

  • Am I just misunderstanding the docs?
  • Are the docs wrong, and the quoted sentence should be removed?
  • Is the implementation wrong, and 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:
❯ node --run ''
Welcome to Node.js v22.5.0.
Type ".help" for more information.
>

Giving the empty string to --run does not try to execute { "scripts": { "": "echo hi" } }. Neither does npm run '' though :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions