Skip to content

[Docs] incorrect example code and explanation in learn/command-line #8323

@tenkirin

Description

@tenkirin

Affected URL

https://nodejs.org/en/learn/command-line/run-nodejs-scripts-from-the-command-line#using-the---run-flag

Describe the issue in detail:

Firstly, the explanation is incorrect:

The syntax -- --another-argument is used to pass arguments to the command. In this case, the --watch argument is passed to the dev script.

In the example code

{
  "type": "module",
  "scripts": {
    "start": "node app.js",
    "dev": "node --run start -- --watch",
    "test": "node --test"
  }
}

the --watch argument is passed to the start script instead of the dev.

Secondly, it doesn't work as expected after running node --run dev. The result of it is node app.js --watch, not node --watch app.js. I think the example is easy to understand and demonstrates a common case, but it is broken.

Metadata

Metadata

Assignees

No one assigned

    Labels

    contentIssues/pr concerning contentlearnIssues/pr concerning the learn section

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions