2

What's the difference between npm run build and npm install webpack?

In what ways these commands differ

  • npm run build executes the script 'build' in package.json. npm install webpack installs the package 'webpack' in your project – Chris Li Sep 29 '19 at 02:34
  • 2
    Possible duplicate of [What is the difference between npm install and npm run build?](https://stackoverflow.com/questions/43664200/what-is-the-difference-between-npm-install-and-npm-run-build) – Aras Sep 29 '19 at 05:57
  • webpack tool ---> npm run build (command in package.json) -----> create bundles. So is this order correct? – Little_Programmer Sep 29 '19 at 06:02
  • @Little_Programmer the correct order is npm run build (command in package.json) --> which runs webpack script (webpack tool) --> and then webpack reads the configurations(if any) and creates bundles. – Abhishek Sep 29 '19 at 17:56
  • https://medium.com/javascript-training/beginner-s-guide-to-webpack-b1f1a3638460 – Abhishek Sep 29 '19 at 17:57

1 Answers1

1

webpack is a module bundler for javascript application. In order to run webpack ypu need to get the webapck in your project.npm install webpack will install webpack from node module software library using npm install webpack command.

npm run build is a separate command to build the code. If you open package.json inside scripts you may see a key like build example

scripts:{
 build:someValue
}
brk
  • 48,835
  • 10
  • 56
  • 78
  • ok, if I have not declared "npm run build" in package.json then nothing will happen. Scripts in package.json what value should I give to make the "npm run build" work. My question is are we pointing the Webpack tool in the package.json to execute the "npm run build". ? – Little_Programmer Sep 29 '19 at 05:37
  • Then can we define a webpack as build tool? – Little_Programmer Sep 29 '19 at 05:50