When I run npm build, it gives this error:
npm WARN build `npm build` called with no arguments
So, what's the difference between npm run-script build and npm build?
When I run npm build, it gives this error:
npm WARN build `npm build` called with no arguments
So, what's the difference between npm run-script build and npm build?
npm run-script is a way to execute arbitrary commands specific to the project/package. Check your applicable package.json file, which will have defined what happens when you execute npm run-script build for that package. It may also include what happens when you run common commands, such as npm run-script test.
As you can see in the documentation for npm run-script, this arbitrary command can include arguments, which you need to refer to your package.json to learn more about.
npm build is not a unique command to the package, and is a native command that ships with npm, as you can see in its documentation.
The best answer is in this SO article.
Basically...
npm run == npm run-script
Plus, certain common tasks are aliased so that the following are true...
npm test == npm run-script test
npm build == npm run-script build
For common tasks, use...
npm start
npm build
npm test
npm restart
And for all others, use...
npm run <my-task>