0

This is more of a conceptual question.

In Package.JSON file we have devDependencies and Dependencies. I understand what each is for. But are these in place simply to make it clearer to other developers what the dev dependencies and the production dependencies are when we distribute our files? If we weren't distributing our files would it make a difference if we put the devDependencies in the dependencies section? In my mind it shouldn't because the package.json is just used for npm installation and when we run our app through a bundler such as webpack it will only bundle up the modules required for deployment. In fact if we are not distributing our files theoretically do we even need a package.JSON file (although I see why we would want one so that we can move files from one place to another easily and just reinstall modules at the other end).

The Dude
  • 1
  • 2
  • 4
    Possible duplicate of [What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?](http://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies) – Ryan Maffey Feb 16 '17 at 12:16
  • **No, it's not a duplicate** because second question asks is there a difference if you don't publish and asks about difference from a pragmatic perspective. Reviewers: please reading the questions thoroughly. – revelt Feb 17 '17 at 10:00

1 Answers1

0

I believe this is a unique question because it asks not just what is the difference between dev and normal deps, but theoretically, is there are difference between the two if you don't publish. Allegedly duplicate answer does not talk about that, yet it's important for people's proper understanding of npm.


Back on your questions:

But are these in place simply to make it clearer to other developers what the dev dependencies and the production dependencies are when we distribute our files?

No. NPM will behave differently depending is it dev or "normal" dep. See more on alleged duplicate's accepted answer. For example, when you install published package, install doesn't install dev dependencies unless you explicitly request via a flag.

If we weren't distributing our files would it make a difference if we put the devDependencies in the dependencies section?

No difference functionality wise only if you don't publish. Besides being a bad practice, difficult to maintain and so on, of course.

Community
  • 1
  • 1
revelt
  • 2,312
  • 1
  • 25
  • 37