From 7dd0dfc59c861e7d3e30a86a8e6db10872fc6b44 Mon Sep 17 00:00:00 2001 From: Michael Garvin Date: Fri, 8 Jan 2021 10:20:24 -0800 Subject: [PATCH] fix(docs): clean up `npm start` docs Adds an example, and a note about how this differs than node's default behavior PR-URL: https://github.com/npm/cli/pull/2459 Credit: @wraithgar Close: #2459 Reviewed-by: @darcyclarke --- docs/content/commands/npm-start.md | 32 +++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/content/commands/npm-start.md b/docs/content/commands/npm-start.md index 8083bf8b7818e..4791719b592f6 100644 --- a/docs/content/commands/npm-start.md +++ b/docs/content/commands/npm-start.md @@ -12,13 +12,39 @@ npm start [-- ] ### Description -This runs an arbitrary command specified in the package's `"start"` property of -its `"scripts"` object. If no `"start"` property is specified on the -`"scripts"` object, it will run `node server.js`. +This runs a predefined command specified in the `"start"` property of +a package's `"scripts"` object. + +If the `"scripts"` object does not define a `"start"` property, npm +will run `node server.js`. + +Note that this is different from the default node behavior of running +the file specified in a package's `"main"` attribute when evoking with +`node .` As of [`npm@2.0.0`](https://blog.npmjs.org/post/98131109725/npm-2-0-0), you can use custom arguments when executing scripts. Refer to [`npm run-script`](/commands/npm-run-script) for more details. +### Example + +```json +{ + "scripts": { + "start": "node foo.js" + } +} +``` + +```bash +npm start + +> npm@x.x.x start +> node foo.js + +(foo.js output would be here) + +``` + ### See Also * [npm run-script](/commands/npm-run-script)