Do you put Babel and Webpack in devDependencies or Dependencies?

Solution 1:

The babel and webpack packages will go into the devDependencies section because these packages are used in when transpiling and bundle-ing your code into vanilla javascript in the bundle.js & etc file(s).

In production you will run your code off the bundle.js build/generated code will not require these dependencies anymore.

Solution 2:

Despite what basically everyone says, I'm going to offer a piece of sanity... it's really quite simple:

Is your project going to be npm installed by another project? a.k.a are you authoring a npm module? will it end up in another projects package.json?

No?

Then put everything in dependencies.

Yes?

  • dependencies: Things you want downstream consumers and project developers of your project to have installed:
  • peerDependencies: Things your downstream users need to make sure they have installed
  • bundleDependencies: Things your downstream users will need, and won't need to install separately because when you npm publish, these will be "bundled" with your package.
  • optionalDependencies: Things that are nice to have but the absence of will not cause fatal error
  • devDependencies: things only used while working on your project.

The short of it is this: modules do not magically get installed differently. They either get installed or they do not.