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

fix(learn): Correct unclear example of passing arguments using the task runner

Open fellowseb opened this issue 1 month ago • 8 comments

Description

Alters the phrasing used in the Passing arguments to the command section of the Run Node.js scripts from the command line page as it is incorrect:

Also, changes the example as current one can confuse the reader into thinking it's a good example of enabling the Node.js watch option even though it's just passing an '--watch' argument to the app.js script (node app.js --watch).

Current docs:

{
  "type": "module",
  "scripts": {
    "start": "node app.js",
    "dev": "node --run start -- --watch",
    "test": "node --test"
  }
}
[...]
In this case, the --watch argument is passed to the dev script.

Updated docs:

{
  "type": "module",
  "scripts": {
    "start": "node app.js",
    "test": "node --test",
    "test:junit": "node --run test -- --test-reporter=\"junit\"",
  }
}
[...]
In this case, the `--test-reporter` argument is passed to the `node --test` command defined by the `test` script.

Validation

  • Run the example scripts locally

Related Issues

None

Check List

  • [x] I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • [x] I have run pnpm format to ensure the code follows the style guide.
  • [x] I have run pnpm test to check if all tests are passing.
  • [x] I have run pnpm build to check if the website builds without errors.

fellowseb avatar Dec 13 '25 21:12 fellowseb