nodejs.org
nodejs.org copied to clipboard
[Docs] incorrect example code and explanation in learn/command-line
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-argumentis used to pass arguments to the command. In this case, the--watchargument is passed to thedevscript.
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.