From bb787ffddadc152c63842ff8f2d1f24d6464ed8b Mon Sep 17 00:00:00 2001 From: Venkat Date: Sun, 12 Apr 2026 08:41:46 +0530 Subject: [PATCH] docs: update argument passing example by replacing the dev script with a port configuration explanation --- .../run-nodejs-scripts-from-the-command-line.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pages/command-line/run-nodejs-scripts-from-the-command-line.md b/pages/command-line/run-nodejs-scripts-from-the-command-line.md index b4260dc..7af998e 100644 --- a/pages/command-line/run-nodejs-scripts-from-the-command-line.md +++ b/pages/command-line/run-nodejs-scripts-from-the-command-line.md @@ -69,7 +69,6 @@ The [`--run`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--run) flag allo "type": "module", "scripts": { "start": "node app.js", - "dev": "node --run start -- --watch", "test": "node --test" } } @@ -83,14 +82,16 @@ node --run test ### Passing arguments to the command -Let's explain the `dev` key in the `scripts` object of the `package.json` file. - -The syntax `-- --another-argument` is used to pass arguments to the command. In this case, the `--watch` argument is passed to the `dev` script. +You can use the syntax `-- --another-argument` to pass arguments to the underlying script. For example, if you want to pass a `--port` argument to the `start` script: ```bash -node --run dev +node --run start -- --port 8080 ``` +This will run the `start` script and append `--port 8080` to the command execution, making it equivalent to running `node app.js --port 8080`. + +> Note: Arguments passed after `--` are forwarded to the script and are not interpreted as Node.js CLI flags. For example, `--watch` would not behave like `node --watch app.js` when passed this way. + ### Environment variables The `--run` flag sets specific environment variables that can be useful for your scripts: