Creating a NodeJS application

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.

The variables we will use here that you need to change with your parameters are:

  • app is the application's root folder and uri
  • example stands for username
  • example.com domain example
  • app.js is the startup file of the application you are creating
  • My app is a description of your application
  • 10,11,12 is the version of your nodejs application 

The first step is to create a cPanel login and find the NodeJS icon

cpanelsetupnodejs Kreiranje NodeJS aplikacije

After that, click on the button to create an application

cpanelnodejscreate Kreiranje NodeJS aplikacije

Then comes the main thing, which is the settings of your application

nodejsapp Kreiranje NodeJS aplikacije
  • Node.js version – select your version of nodejs
  • Application mode – choose whether the application will be in development or ready for the public
  • Application root – this is where you set the app's system files usually in /home/username a typical app location is /home/username/appname
  • Application URL – the url address of your application on the Internet
  • Application startup file – the initial file of your application that will be launched after starting your application

To finish, click on the "Create" button.

packedjsrequired Kreiranje NodeJS aplikacije

This is the message you will get immediately as soon as you create. And you solve it in the following way.

On the cPanel home page, click on File Manager then go to the root of your app and then the top left corner New File and create a package.json file.

packagejsaplikacija Kreiranje NodeJS aplikacije

Now that we have created that file we need to right click on package.json and click Edit in the new tab, a code editor will appear where you need to enter the content of that file.

For an example of this tutorial, enter the content of the following content:

{ "name": "app", "version": "1.0.0", "description": "My App", "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC" }

Save it. After that you need to go back to the Home page of cPanel and go back to the nodeJS application.

cpanelsetupnodejs Kreiranje NodeJS aplikacije

In the application list, click on the pencil that is there as a button Edit

editaplikacija Kreiranje NodeJS aplikacije

Now all that's left is to click the Run NPM install button and you've installed your application.

runnpminstall Kreiranje NodeJS aplikacije

Once that is done, the application has been successfully installed.

instliranonodejs Kreiranje NodeJS aplikacije

In order to run other NPM commands related to your application you need SSH access. Instructions for SSH access. And you need to copy the command line that appeared to you in the orange square (or purple, gray..)

pokretanjenpm Kreiranje NodeJS aplikacije

When you connect via SSH, you should run that command (just copy paste).

source /home/example/nodevenv/app/11/bin/activate && cd /home/example/app

You have now installed the application and can use npm commands.

Scroll to Top