{"id":969,"date":"2021-12-20T21:04:14","date_gmt":"2021-12-20T15:19:14","guid":{"rendered":"http:\/\/babal.host\/blog\/?p=969"},"modified":"2023-01-04T19:09:51","modified_gmt":"2023-01-04T13:24:51","slug":"how-to-setup-install-and-deploy-your-node-js-application-with-babal-host","status":"publish","type":"post","link":"https:\/\/babal.host\/blog\/how-to-setup-install-and-deploy-your-node-js-application-with-babal-host\/","title":{"rendered":"How to Setup, Install and Deploy your Node Js Application with Babal Host?"},"content":{"rendered":"<p>You can get Node js package in Babal Host, in the following packages.<\/p>\n<ul>\n<li>Node js Starter Package<\/li>\n<li>Node js Pro Package<\/li>\n<li>Professional Plan<\/li>\n<\/ul>\n<p>Node js is an open source server environment that runs on various platforms i.e. Windows, Linux, Mac OSx, UNIX. It uses javascript on the server.<\/p>\n<p>Here are the following procedures to follow for setting up the Node js application in the cPanel interface.<\/p>\n<ol>\n<li>Login to your cPanel. If you do not know how to log in to your cPanel, follow <a href=\"https:\/\/babal.host\/blog\/how-to-open-cpanel-for-your-website\/\" target=\"_blank\" rel=\"noopener\">this article<\/a>.<\/li>\n<li>Scroll down, and in the Software section, select the &#8220;Setup Node js App&#8221;.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-972 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.jpg\" alt=\"Setup Node js App\" width=\"956\" height=\"316\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.jpg 956w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1-300x99.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1-768x254.jpg 768w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/li>\n<li>Click on Create Application.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-974 size-large\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/cerating-application-1024x256.jpg\" alt=\"cerating application\" width=\"1024\" height=\"256\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/cerating-application-1024x256.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/cerating-application-300x75.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/cerating-application-768x192.jpg 768w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/cerating-application.jpg 1308w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/li>\n<li>Fill in the form below, as filled in the photo, and click on the create button.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-975 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/setting-up-the-files.jpg\" alt=\"setting up the files\" width=\"1303\" height=\"593\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/setting-up-the-files.jpg 1303w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/setting-up-the-files-300x137.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/setting-up-the-files-1024x466.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/setting-up-the-files-768x350.jpg 768w\" sizes=\"auto, (max-width: 1303px) 100vw, 1303px\" \/><br \/>\n&#8211; <b>Node.js version<\/b>: Select your preferred version from the drop-down list.<br \/>\n&#8211; <b>Application Mode<\/b>: Choose development or production from the list. For testing, you can initially use development, later on during launch you can change it to Production.<br \/>\n&#8211; <b>Application root<\/b>: It is the file system location for application files. The entry should be \/home\/username to form the complete path in the cPanel home directory.<br \/>\n&#8211; <b>Application URL<\/b>: It is the public URL to the application.<br \/>\n&#8211;<b>Application Startup file<\/b>: The initial file will first be loaded while launching the application.<\/li>\n<li>The following screen will appear after clicking on create button.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-976 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/app-created.jpg\" alt=\"app created\" width=\"1280\" height=\"409\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/app-created.jpg 1280w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/app-created-300x96.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/app-created-1024x327.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/app-created-768x245.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/li>\n<li>Open your site by using the URL: &lt;domainname&gt;.com\/app<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-977 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/it-works-node-js.jpg\" alt=\"it works node js\" width=\"850\" height=\"236\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/it-works-node-js.jpg 850w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/it-works-node-js-300x83.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/it-works-node-js-768x213.jpg 768w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/>It works.\u00a0 This is how the working application is installed. We need to enhance the environment with the package.json settings file and the npm package manager. Follow the article below for creating package.json file and installing npm.<\/li>\n<\/ol>\n<p>#<strong>Creating package.json file<\/strong><\/p>\n<p>For creating the package.json file, follow the following steps below.<\/p>\n<ol>\n<li>Go to File Manager in cPanel.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-981 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.1.jpg\" alt=\"opening file manager\" width=\"971\" height=\"312\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.1.jpg 971w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.1-300x96.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.1-768x247.jpg 768w\" sizes=\"auto, (max-width: 971px) 100vw, 971px\" \/><\/li>\n<li>Open the app folder inside the domain folder where you setup the node.js app.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-982 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/opening-app-folder.jpg\" alt=\"opening app folder\" width=\"1030\" height=\"157\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/opening-app-folder.jpg 1030w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/opening-app-folder-300x46.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/opening-app-folder-1024x156.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/opening-app-folder-768x117.jpg 768w\" sizes=\"auto, (max-width: 1030px) 100vw, 1030px\" \/><\/li>\n<li>Click on the +File icon to create the new file.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-983 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-file.jpg\" alt=\"adding file\" width=\"1364\" height=\"431\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-file.jpg 1364w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-file-300x95.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-file-1024x324.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-file-768x243.jpg 768w\" sizes=\"auto, (max-width: 1364px) 100vw, 1364px\" \/><\/li>\n<li>Name the filename as package.json and click on Create New File button.<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-984 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/file-naming.jpg\" alt=\"file naming\" width=\"512\" height=\"264\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/file-naming.jpg 512w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/file-naming-300x155.jpg 300w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/li>\n<li>Right-click on the package.json file and click on the edit button.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-985 size-medium\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/clicking-on-edit-300x237.jpg\" alt=\"clicking on edit\" width=\"300\" height=\"237\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/clicking-on-edit-300x237.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/clicking-on-edit.jpg 408w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/li>\n<li>Add the following code in the file and click on Save Changes and then click on close button.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-986 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-the-codes.jpg\" alt=\"adding the codes\" width=\"1365\" height=\"363\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-the-codes.jpg 1365w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-the-codes-300x80.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-the-codes-1024x272.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/adding-the-codes-768x204.jpg 768w\" sizes=\"auto, (max-width: 1365px) 100vw, 1365px\" \/><br \/>\nCode:<\/p>\n<pre class=\"code\">{\r\n  \"name\": \"app\",\r\n  \"version\": \"1.0.0\",\r\n  \"description\": \"My App\",\r\n  \"main\": \"app.js\",\r\n  \"scripts\": {\r\n    \"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\r\n  },\r\n  \"author\": \"\",\r\n  \"license\": \"ISC\"\r\n}\r\n\r\n<\/pre>\n<\/li>\n<\/ol>\n<p>The code for the package.json is completed. Lets go through the npm install command.<\/p>\n<h4><strong>#<\/strong><strong>npm install\u00a0<\/strong><\/h4>\n<p>Follow the below steps to install npm to the node.js app<\/p>\n<ol>\n<li>Open your cPanel, scroll down and in Software section, Click on &#8220;Setup Node App&#8221; option.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-972 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.jpg\" alt=\"Setup Node js App\" width=\"956\" height=\"316\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1.jpg 956w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1-300x99.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/1-768x254.jpg 768w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/li>\n<li>Click on the pencil icon, editing the application.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-993 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/editing-the-application.jpg\" alt=\"editing the application\" width=\"1305\" height=\"279\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/editing-the-application.jpg 1305w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/editing-the-application-300x64.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/editing-the-application-1024x219.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/editing-the-application-768x164.jpg 768w\" sizes=\"auto, (max-width: 1305px) 100vw, 1305px\" \/><\/li>\n<li>\u00a0Scroll down a bit, click on run NPM Install button. This might take some time to detect the file by this application. It might take 10-20 minutes to install.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-994 size-full\" src=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/run-npm-install.jpg\" alt=\"run npm install\" width=\"1026\" height=\"146\" srcset=\"https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/run-npm-install.jpg 1026w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/run-npm-install-300x43.jpg 300w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/run-npm-install-1024x146.jpg 1024w, https:\/\/babal.host\/blog\/wp-content\/uploads\/2021\/04\/run-npm-install-768x109.jpg 768w\" sizes=\"auto, (max-width: 1026px) 100vw, 1026px\" \/><\/li>\n<li>The npm install runs and displays the success indicator of completing the task.<\/li>\n<\/ol>\n<h4><strong>#for installing packages with npm and performing the command-related tasks<\/strong><\/h4>\n<p>See the following steps for setup the node js app and doing the command-related tasks.<\/p>\n<ol>\n<li>Connect to your account to login through SSH.<\/li>\n<li>Create the node js application with the command below.\n<pre class=\"command\">cloudlinux-selector create --json --interpreter nodejs --version 11 --app-root app --domain example.com --app-uri app<\/pre>\n<\/li>\n<li>During inside the home directory, change the directory into the application directory.\n<pre class=\"command\">cd ~\/app<\/pre>\n<\/li>\n<li>Open the vi editor and create the package.json file\n<pre class=\"command\">vi package.json<\/pre>\n<\/li>\n<li>Enter i to change to the insert mode and paste the following code in the text editor.\n<pre>{\r\n\"name\": \"app\",\r\n\"version\": \"1.0.0\",\r\n\"description\": \"My App\",\r\n\"main\": \"app.js\",\r\n\"scripts\": {\r\n\"test\": \"echo \\\"Error: no test specified\\\" &amp;&amp; exit 1\"\r\n},\r\n\"author\": \"\",\r\n\"license\": \"ISC\"\r\n}<\/pre>\n<\/li>\n<li>Enter escape followed by : to enter command mode.<\/li>\n<li>Enter x followed by Enter to save and exit the editor.<\/li>\n<li>Now, install npm using the following command.|\n<pre class=\"command\">cloudlinux-selector install-modules --json --interpreter nodejs --user example --app-root app<\/pre>\n<\/li>\n<li>For installing packages with npm and performing other command-line tasks, log in with ssh and type the following command to enter the virtual environment of the application.\n<pre class=\"command\">source \/home\/example\/nodevenv\/app\/11\/bin\/activate &amp;&amp; cd \/home\/example\/app<\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>You can get Node js package in Babal Host, in the following packages. Node js Starter Package Node js Pro Package Professional Plan Node js is an open source server environment that runs on various platforms i.e. Windows, Linux, Mac OSx, UNIX. It uses javascript on the server. Here are the following procedures to follow [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":1142,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-969","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-babal-guide"],"_links":{"self":[{"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/posts\/969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/comments?post=969"}],"version-history":[{"count":12,"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/posts\/969\/revisions"}],"predecessor-version":[{"id":1280,"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/posts\/969\/revisions\/1280"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/media\/1142"}],"wp:attachment":[{"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/media?parent=969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/categories?post=969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/babal.host\/blog\/wp-json\/wp\/v2\/tags?post=969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}