効率的なNode.js開発: concurrentlyでの同時実行とnodemonによる自動再起動

Nodejsで複数のアプリケーションを同時に実行する方法

クライアント、認証サーバー、プロテクトサーバーを同時に動かす方法 Git

npm i concurrently
npm i nodemon

package.jsonのscriptsを追加する

{
  "dependencies": {
    "body-parser": "^1.13.2",
    "consolidate": "^0.13.1",
    "cors": "^2.7.1",
    "express": "^4.13.1",
    "nosql": "^6.1.0",
    "qs": "^6.9.3",
    "randomstring": "^1.0.7",
    "sync-request": "^2.0.1",
    "underscore": "^1.8.3",
    "underscore.string": "^3.1.1"
  },
  "scripts": {
    "start": "concurrently \"nodemon authorizationServer.js\" \"nodemon protectedResource.js\" \"nodemon client.js\""
  },  
  "devDependencies": {
    "concurrently": "^8.2.1",
    "nodemon": "^3.0.1"
  }
}
  • concurrently
    • 複数のコマンドを同時に実行します
  • nodemon
    • ファイルの変更を監視し、変更が検出されたときに自動でNode.jsアプリケーションを再起動する
      • file編集したら反映してくれるので、必要であればInstallする

関連記事