{"id":2392,"date":"2020-03-07T18:27:22","date_gmt":"2020-03-07T17:27:22","guid":{"rendered":"https:\/\/www.webhostingsrbija.rs\/?p=2267"},"modified":"2020-03-07T18:27:22","modified_gmt":"2020-03-07T17:27:22","slug":"kreiranje-nodejs-aplikacije","status":"publish","type":"post","link":"https:\/\/www.webhostingsrbija.rs\/en\/kreiranje-nodejs-aplikacije\/","title":{"rendered":"Creating a NodeJS application"},"content":{"rendered":"<p class=\"wp-block-paragraph\">In cPanel if you have the appropriate package you will easily find a NodeJs option to create an application with one click. In this tutorial, we will walk you through the entire process of creating an app and getting it up and running.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The variables we will use here that you need to change with your parameters are:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>app<\/strong>\u00a0is the application&#039;s root folder and uri<\/li><li><strong>example<\/strong>\u00a0stands for username<\/li><li><strong>example.com<\/strong>\u00a0domain example<\/li><li><strong>app.js<\/strong>\u00a0is the startup file of the application you are creating<\/li><li><strong>My app<\/strong>\u00a0is a description of your application<\/li><li><strong>10,11,12<\/strong> is the version of your nodejs application\u00a0<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The first step is to create a cPanel login and find the NodeJS icon<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/cpanelsetupnodejs.jpg\" alt=\"\" class=\"wp-image-2268\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">After that, click on the button to create an application<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/cpanelnodejscreate.jpg\" alt=\"\" class=\"wp-image-2269\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then comes the main thing, which is the settings of your application<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/nodejsapp.jpg\" alt=\"\" class=\"wp-image-2270\" title=\"\"><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Node.js version<\/strong>\u00a0\u2013 select your version of nodejs<\/li><li><strong>Application mode<\/strong>\u00a0\u2013 choose whether the application will be in development or ready for the public<\/li><li><strong>Application root<\/strong>\u00a0\u2013 this is where you set the app&#039;s system files usually in \/home\/username a typical app location is \/home\/username\/appname<\/li><li><strong>Application URL<\/strong>\u00a0\u2013 the url address of your application on the Internet<\/li><li><strong>Application startup file<\/strong>\u00a0\u2013 the initial file of your application that will be launched after starting your application<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">To finish, click on the &quot;Create&quot; button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/packedjsrequired.jpg\" alt=\"\" class=\"wp-image-2271\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This is the message you will get immediately as soon as you create. And you solve it in the following way.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the cPanel home page, click on <strong>File Manager<\/strong> then go to the root of your app and then the top left corner <strong>New File<\/strong> and create a package.json file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/packagejsaplikacija.jpg\" alt=\"\" class=\"wp-image-2272\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we have created that file we need to right click on package.json and click <strong>Edit<\/strong> in the new tab, a code editor will appear where you need to enter the content of that file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For an example of this tutorial, enter the content of the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{ &quot;name&quot;: &quot;app&quot;, &quot;version&quot;: &quot;1.0.0&quot;, &quot;description&quot;: &quot;My App&quot;, &quot;main&quot;: &quot;app.js&quot;, &quot;scripts&quot;: { &quot;test&quot;: &quot;echo \\&quot;Error: no test specified\\&quot; &amp;&amp; exit 1&quot; }, &quot;author&quot;: &quot;&quot;, &quot;license&quot;: &quot;ISC&quot; }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save it. After that you need to go back to the Home page of cPanel and go back to the nodeJS application.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/cpanelsetupnodejs.jpg\" alt=\"\" class=\"wp-image-2268\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the application list, click on the pencil that is there as a button <strong>Edit<\/strong> <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/editaplikacija.jpg\" alt=\"\" class=\"wp-image-2273\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now all that&#039;s left is to click the Run NPM install button and you&#039;ve installed your application.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/runnpminstall.jpg\" alt=\"\" class=\"wp-image-2274\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once that is done, the application has been successfully installed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/instliranonodejs.jpg\" alt=\"\" class=\"wp-image-2275\" title=\"\"><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In order to run other NPM commands related to your application you need SSH access. <a href=\"https:\/\/www.webhostingsrbija.rs\/en\/kako-da-se-povezete-na-ssh-cpanel-bitvise\/\">Instructions for SSH access<\/a>. And you need to copy the command line that appeared to you in the orange square (or purple, gray..)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img fetchpriority=\"high\" decoding=\"async\" width=\"557\" height=\"94\" src=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/pokretanjenpm.jpg\" alt=\"\" class=\"wp-image-2276\" title=\"\" srcset=\"https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/pokretanjenpm.jpg 557w, https:\/\/www.webhostingsrbija.rs\/wp-content\/uploads\/2020\/03\/pokretanjenpm-300x51.jpg 300w\" sizes=\"(max-width: 557px) 100vw, 557px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When you connect via SSH, you should run that command (just copy paste).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source \/home\/example\/nodevenv\/app\/11\/bin\/activate &amp;&amp; cd \/home\/example\/app<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You have now installed the application and can use npm commands.<\/p>","protected":false},"excerpt":{"rendered":"<p>U cPanelu ako imate odgovaraju\u0107i paket lako \u0107ete na\u0107i NodeJs opciju za kreiranje aplikacije putem jednog klika. Kroz ovaj tutorijal pro\u0107i \u0107emo kroz ceo proces kreiranja aplikacije i pokretanje. Varijable koje \u0107emo koristit ovde koje treba da promenite sa svojim parametrima su: app\u00a0je root folder aplikacije i uri example\u00a0stoji za username example.com\u00a0primer domena app.js\u00a0je startup [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2277,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[20],"tags":[30,65],"class_list":["post-2392","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpanel","tag-cpanel","tag-nodejs"],"_links":{"self":[{"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/posts\/2392","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/comments?post=2392"}],"version-history":[{"count":0,"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/posts\/2392\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/media\/2277"}],"wp:attachment":[{"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/media?parent=2392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/categories?post=2392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhostingsrbija.rs\/en\/wp-json\/wp\/v2\/tags?post=2392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}