{"id":2498,"date":"2017-06-23T06:14:58","date_gmt":"2017-06-23T06:14:58","guid":{"rendered":"https:\/\/intelligentbee.com\/blog\/?p=2498"},"modified":"2024-11-28T14:13:03","modified_gmt":"2024-11-28T14:13:03","slug":"automatically-restart-node-app-nodemon","status":"publish","type":"post","link":"https:\/\/intelligentbee.com\/blog\/automatically-restart-node-app-nodemon\/","title":{"rendered":"Automatically Restart Your Node.js Application"},"content":{"rendered":"<p>Many of us write code on Node.js, click [CTRL+S] to save the file but forget to restart the application.<\/p>\n<p>If we don&#8217;t forget to restart the application we will go in console and hit [CTRL+C] to stop the application and then restart it by pressing the [UP] arrow and [Enter].<\/p>\n<h2>Nodemon<\/h2>\n<p>You can automate this repetitive task and make your development process easier by using `<em>nodemon<\/em>`.<\/p>\n<p>`<em>nodemon<\/em>` will watch the files and if any files were changed, the `<em>nodemon<\/em>` will automatically restart your node application.<\/p>\n<p>First, you need to install `<em>nodemon<\/em>`:<\/p>\n<pre class=\"lang:default decode:true \">npm install nodemon -g<\/pre>\n<p>Now, you should swap the `node` command for the `nodemon` command:<\/p>\n<pre class=\"lang:default decode:true \">$ nodemon app.js\r\n[nodemon] 1.11.0\r\n[nodemon] to restart at any time, enter `rs`\r\n[nodemon] watching: *.*\r\n[nodemon] starting `node app.js`\r\n[nodemon] restarting due to changes...\r\n[nodemon] starting `node app.js`<\/pre>\n<h6>Read about: <a href=\"https:\/\/intelligentbee.com\/blog\/how-set-up-node-js-development-environment\/\">How to set up a Node.Js<\/a><a href=\"https:\/\/intelligentbee.com\/blog\/how-set-up-node-js-development-environment\/\"> develop<\/a><a href=\"https:\/\/intelligentbee.com\/blog\/how-set-up-node-js-development-environment\/\">ment<\/a><a href=\"https:\/\/intelligentbee.com\/blog\/how-set-up-node-js-development-environment\/\"> environment<\/a><\/h6>\n<p>If you need to manually restart your application, instead of stopping and restart `nodemon`, you can simply type `rs` on your console.<\/p>\n<pre class=\"lang:default decode:true\">[nodemon] starting `node app.js`\r\nrs\r\n[nodemon] starting `node app.js`<\/pre>\n<p>Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many of us write code on Node.js, click [CTRL+S] to save the file but forget to restart the application. If [&hellip;]<\/p>\n","protected":false},"author":28,"featured_media":2518,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,81],"tags":[180,181,211],"yst_prominent_words":[384,471,1053,1396,1888],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts\/2498"}],"collection":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/comments?post=2498"}],"version-history":[{"count":3,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts\/2498\/revisions"}],"predecessor-version":[{"id":133342,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/posts\/2498\/revisions\/133342"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/media\/2518"}],"wp:attachment":[{"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/media?parent=2498"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/categories?post=2498"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/tags?post=2498"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/intelligentbee.com\/blog\/wp-json\/wp\/v2\/yst_prominent_words?post=2498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}