Skip to content

Commit bb787ff

Browse files
VenkatVenkat
authored andcommitted
docs: update argument passing example by replacing the dev script with a port configuration explanation
1 parent 413106b commit bb787ff

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

pages/command-line/run-nodejs-scripts-from-the-command-line.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ The [`--run`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--run) flag allo
6969
"type": "module",
7070
"scripts": {
7171
"start": "node app.js",
72-
"dev": "node --run start -- --watch",
7372
"test": "node --test"
7473
}
7574
}
@@ -83,14 +82,16 @@ node --run test
8382

8483
### Passing arguments to the command
8584

86-
Let's explain the `dev` key in the `scripts` object of the `package.json` file.
87-
88-
The syntax `-- --another-argument` is used to pass arguments to the command. In this case, the `--watch` argument is passed to the `dev` script.
85+
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:
8986

9087
```bash
91-
node --run dev
88+
node --run start -- --port 8080
9289
```
9390

91+
This will run the `start` script and append `--port 8080` to the command execution, making it equivalent to running `node app.js --port 8080`.
92+
93+
> 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.
94+
9495
### Environment variables
9596

9697
The `--run` flag sets specific environment variables that can be useful for your scripts:

0 commit comments

Comments
 (0)