How to determine whether or not to add run to the command defined in scripts of package.json when npm is called?

"scripts": {
    "dev": "node build/dev-server.js",
    "build": "node build/build.js"
},

as mentioned in the question, I always thought that the above commands were invoked in this way

npm run dev
npm run build

when learning the webpack-dev-server chapter of webpack, the official tutorial uses npm start, instead of npm run start,. When to add run, and when not to add run?


usually such as start command, test command can not add run , but dev these commands need to add run . You can edit package.json and try it yourself.


you can refer to the official documentation. Except for the commands in [this command list] , you need to add run in all cases.

reference address: How npm handles the" scripts "field


the easiest way is to add run,. Of course, npm start can be used as a special treatment

Menu