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
?
ionic build uses ng build internally. If you run ng build directly, Ionic hooks won't be triggered as it is bypassed. npm run build picks the "build" from package. json which is the same as ng build .
foreground-scripts Run all build scripts (ie, preinstall , install , and postinstall ) scripts for installed packages in the foreground process, sharing standard input, output, and error with the main npm process.
npm install installs dependencies into the node_modules/ directory, for the node project you're working on. You can call install on another node. js project (module), to install it as a dependency for your project. npm run build does nothing unless you specify what "build" does in your package.
npm run serve is basically asking the package manager (npm) to run the command specified under the name serve in the package. json file. The same goes for the npm run dev command. It is possible that both execute the same command or different things.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With