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.
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:
In the example code
the
--watchargument is passed to thestartscript instead of thedev.Secondly, it doesn't work as expected after running
node --run dev. The result of it isnode app.js --watch, notnode --watch app.js. I think the example is easy to understand and demonstrates a common case, but it is broken.