0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【package.json】"dependencies"と"devDependencies"の違い

Last updated at Posted at 2025-09-15

🔹依存関係が2種類ある理由

Node.js / npm には「アプリ本番で必要なもの」と「開発中だけ必要なもの」があるから。
それを分けるために dependencies と devDependencies がある。

🔹dependencies

  • 本番環境Production)でも必要なライブラリ
    つまりアプリが動くために必須のもの。

  • 本番デプロイ先(Vercel, AWS, etc.)にもインストールされる

  • 例:
    react(UIライブラリ)
    next(フレームワーク)
    express(サーバー)
    @auth/prisma-adapter(認証アダプター)

package.json
"dependencies": {
  "next": "^15.0.0",
  "react": "^18.3.0",
  "@auth/prisma-adapter": "^1.0.0"
}
  • インストールコマンド
npm install react

🔹devDependencies

  • 開発環境にしか必要ないライブラリ

  • 本番アプリの実行には不要

  • 例:
    typescript(型チェック用)
    eslint(Lintツール)
    @types/*(型定義ファイル)
    vitest jest(テストフレームワーク)

package.json
"devDependencies": {
  "typescript": "^5.6.0",
  "@types/react": "^18.3.0",
  "eslint": "^9.0.0"
}
  • インストールコマンド
npm install -D typescript
# または
npm install --save-dev typescript

🔹具体例(Next.js プロジェクト)

  • react → UI を描画するために 本番でも必要 → dependencies

  • @types/react → 開発中の型補完用、本番には不要 → devDependencies

🔹まとめ

  • dependencies → 本番でも必要(動作に必須)
  • devDependencies → 開発専用(型チェック、Lint、テストなど)
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?