DEV Community


Discussion on: Is React a dev or prod npm dependency?

sergiodxa profile image
Sergio Daniel Xalambrí

I use dependencies for any package I import in the app code.

I use devDependencies for any package I don’t import in the app code (test utils, module bundlers, linters, etc.)

gyandeeps profile image
Gyandeep Singh Author

Well that's the strategy I use too. I was just curious what people thought about it. Technically speaking, if I consume your package via npm I don't need react to be installed since it's already bundled inside your main file.

whiskerfatigue profile image

That's a sensible strategy for authoring libraries.

However for applications the best rule of thumb is: everything you need to build an application is a dependency. So bundlers, linters and tests utils (if linting and tests are part of your build pipleline) are regular dependencies, not devDependencies.

That way it's always safe to use npm ci in your CI pipeline.