0

So I'm building a Front End application based on React. There'll be different packages serving as libraries and exporting components. These components will then be imported into the main package and routed according to need.

Now for the package(s) serving as libraries; I'm trying to understand how to distribute the dependencies between dependencies, devDependencies, and peerDependencies in the package.json file.

Should I be putting everything in dev and peer? Or do things like lodash / babel etc. need to be put in dependencies? Any such best practices; or list of dependencies would be helpful

  • This can be helpful for you: [What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?](https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies) – Max Samusevich Sep 13 '22 at 11:44

1 Answers1

1

About dependencies and devDependencies

Dependencies

"dependencies": Packages required by your application in production.

In dependencies you put everything that is imported in your application or needed in some way in the final application, e.g: react, axios etc.

devDependencies

"devDependencies": Packages that are only needed for local development and testing.

In devDependencies you put only things that are used to build your application, eg. webpack, eslint etc.

peerDependencies

You can read about peerDependencies here

You won't use them unless your project is a library.

Questions:

Should I be putting everything in dev and peer?

No, it's safer to put everything in dependencies if you don't know where to put it.

Or do things like lodash / babel etc. need to be put in dependencies?

No, lodash should be in dependencies, because, you are using it in your website. babel on the other hand is used only in built time, so it should be in devDependencies.

Konrad
  • 21,590
  • 4
  • 28
  • 64