This content originally appeared on DEV Community and was authored by Takuya Kikuchi
How to differentiate them
The basic criteria is whether a package is only needed for development or not.
-
dependencies
: Packages required to execute the application -
devDependencies
: Packages required for development/testing
Examples
dependencies
- react, react-dom
- next
devDependencies
- eslint
- husky
- prettier
- typescript
- jest
What's good about differentiating them
- A developer can easily distinguish what packages needed for development or production
- When production build, faster installation time, less disk usage
=>
$ npm install --production
Commands
Add a package to dependencies
npm
$ npm install <package-name>
Short: $ npm i <package-name>
yarn
$ yarn add <package-name>
.
Add a package to devDependencies
npm
$ npm install <package-name> --save-dev
Short: $ npm i <package-name> -D
yarn
$ yarn add <package-name> --dev
Short: $ yarn add <package-name> -D
Reference
EN
JP
- 【いまさらですが】package.jsonのdependenciesとdevDependencies - Qiita
- 【package.json】dependenciesとdevDependenciesの違いとnpmとyarnのコマンド解説 | モグモグ
- 【package.json】dependencies, devDependencies の使い分けを考える - Qiita
This content originally appeared on DEV Community and was authored by Takuya Kikuchi

Takuya Kikuchi | Sciencx (2021-09-25T01:11:37+00:00) dependencies? devDependencies? ?. Retrieved from https://www.scien.cx/2021/09/25/dependencies-devdependencies-%f0%9f%a4%94/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.