nodejs.org icon indicating copy to clipboard operation
nodejs.org copied to clipboard

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

Open tenkirin opened this issue 2 months ago • 0 comments

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.

tenkirin avatar Nov 03 '25 10:11 tenkirin