LoginSignup
26

More than 5 years have passed since last update.

package.jsonにおけるdependenciesとdevDependenciesの違い(超シンプルに)

Posted at

フロントエンドフレームワークを触っていると目にするpackage.json
(まぁ、他でも目にしますが。。w)

(例)

"dependencies": {
  "@nuxtjs/axios": "^5.3.1",
},
"devDependencies": {
  "eslint": "^5.14.1",
  "jest": "^23.6.0",
},

この中に、dependenciesdevDependenciesの似たようなものがあります。この2つの違いは何なんでしょうか? シンプルに↓↓

dependencies

  • そのnode moduleが実行において依存するパッケージ
  • 開発者以外の人がnpm installすると、こちらのパッケージのみインストールされる (開発者がnpm installコマンドをすると、両方インストールされる)
  • npm install —productionのように、-productionをつけると、dependeniesのみインストール可能

devDependencies

  • node moduleの開発にのみ利用するパッケージ
  • テストやタスクランナー系
  • 開発時のみに必要なライブラリ
  • 実行時には役に立たず、含める必要がないもの

まとめ

そう、devDependenciesdevの部分はdevelopmentdev何です。と考えるとイメージしやすいですね! 開発時に必要なものはdevDependenciesに、本番環境でも必要なものはdependenciesにと覚えておけばいいでしょう。より詳しく知りたい方は、参考であげている記事とかいいですね!

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26