How to Set up Node.js Application in cPanel

In this tutorial, you will learn to set up Node.js applications in the cPanel easily.

  1. Login to the cPanel

2. In the software Section, click on the “Setup Node.js App” as shown in the file below

3) On the Node.js selector page, click the Create Application button.

4. Fill in the required fields on the application setup form. (This is the directory in which you will upload application files), Here, we name the application name “app”.

  • Application Mode: Select the mode from the dropdown list; the mode can be in Development or Production. You can choose Development initially and change it to Production later on.
  • Application Root: application root directory relative to the user’s home
  • Application URL: the public URL to your application
  • Application startup file: the initial file that will be processed when launching the application.

5. Select your Application URL and startup file (if you do not name a startup file, app.js is used as the default)

6. Click Create when ready.

After the application is created, an information box is displayed advising that the package.json is required to Run NPM Install. Please follow the steps below.

How to Create the package.json file

  1. Go back to cPanel’s dashboard. In the FILES section of cPanel, click the File Manager icon to open the File Manager.

In the left-hand column of File Manager, click the text of the application root folder, for the example above, our application folder name is app, so we create package.json inside the app folder.

In the folder, create a new file name package.json.

2. Once the file is created, open the file and enter the following text in the editor.

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

3) Click the Save Changes button to save the file.

Install NPM

  1. Go back to the Setup Node.js App icon
  2. In the Actions column of the Web Applications list, click the pencil icon to edit the application.

3) Click the Run NPM Install button.

The NPM installation runs and presents a success indicator when completed:

Was this article helpful?

Related Articles

Leave A Comment?

This site uses Akismet to reduce spam. Learn how your comment data is processed.