Skip to content

Node Js Hosting – With A Sample ‘Hello World’ Application

Let's dive into some simple and quick steps for all the beginner's of Node.js with a complete hello_world program and detailed informative steps on our Node Js Hosting
Reading Time: 5 minutes
node.js on shared hosting

If you’re interested in hosting Node.js apps, we’ve got good news for you.

Netspace (India) shared hosting services like Linux Hosting and Windows Hosting comes with a Node.js extension that allows you to manage apps easily.

In this article, we’ll describe in detail how to work with Node.js apps in the context of shared hosting program and help you host your first basic “hello world” node.js application in shared hosting environment.

Table of Contents

Node Js Hosting Plan

Netspace (India), Offer Node.js support on our both Linux Hosting Plan and Windows Hosting Plan, This article will guide you to upload your first Node.Js application on our Windows shared hosting and Linux Node Js Hosting platforms which support node.js application. 

Hosting "Hello World" Node.js - On Windows Shared Hosting (Plesk)

Let’s start windows shared hosting platform. 

We support latest version node.js through Plesk, the detail instruction about how we manage node.js on windows Plesk is documented here by plesk.  

You require your Plesk login details (which was mailed to you on activation of your windows shared hosting account).

Login to Plesk, using the detail provided on activation mail. 

Create Your Hello World.js file. : app.js

As soon as you login, you will see a screen just like shown. 

Step 1: Click on File Manager

Step 2: under httpdocs/ creat new directory (for this example we created hello_world)

create_dir_plesk

Step 3: On the directory tree at the left of File Manager, click the newly created hello_world directory:

Step 4: On the toolbar at the top of File Manager, click the New list box, and then click Create File:

create_file

Step 5: In the Create a File dialog box, in the File name text box, type app.js, and then click OK.

Step 6: In the right hand pane of the File Manager, click the name of the new file to open it in the code editor . Then copy and paste the following code into the editor, and click OK.

Hello World Code for node.js (File : app.js) :
const http = require('http');

http.createServer(function(request, response) {
  response.writeHead(200, {'Content-Type': 'text/html'});
  response.end('

Hello World!

‘); }).listen(process.env.PORT); console.log(‘App is running…’);

Configure NODE.JS

Now, that you have created node.js “hello world” code as app.js under Home directory >> httpdocs >> hello_world, let us go ahead and start our node.js application. 

For this you need to come back to home screen of your plesk hosting account.

Step 1 : Look for node.js icon as shown on the screen shot. 

node.js

Step 2: On the node.js configuration page, click the name of the Application Root. A directory tree dialog box appears.

Select the Document Root and Application Root as our node.js application folder.

Step 3: Click Enable Node.js. A confirmation message will appear. You are now ready to test your first node.js application.

In our example we have created node.js “hello world” application at https://plesk.netspaceindia.com/

Hosting "Hello World" Node.js - On Linux Shared Hosting (Cpanel)

Just like windows shared hosting, we support node.js on our Linux shared hosting powered by Cpanel

To host Node.js file on Linux shared hosting, you need to perform three steps. 

Create the application for NODE.JS

Step 1: Login to Cpanel from welcome email.

node.js_selector

Step 2 :  In the SOFTWARE section of Cpanel, click the Setup Node.js App icon to open the Node.js selector:

Step 3: On the Node.js selector page, click CREATE APPLICATION to start the application.

Step 4: Fill in the fields on the application setup form:

Step 5:  When the form is complete, click CREATE.
The application starts automatically. To view a test page for the application, click OPEN.

Now that a working application is installed, you can enhance the environment with the package.json settings file and the npm package manager. To do this, follow the next two procedures.

The package.json file

Step1 : Look for file manager in Cpanel, The icon will look like this :

Step 2: In the left hand column of File Manager, click the text of the application root folder:

Step 3: Click +File to create a new file and In the New File dialog box, type the filename package.json, and then click Create New File once the file is created Right-click or secondary click on the package.json file in the right-hand column of File Manager and then click Edit. An edit dialog box appears:

Step 4:  In the Edit dialog box, click OK and Type the following text in the editor screen:

Hello World Code for node.js (File : package.json) :
{
  "name": "app",
  "version": "1.0.0",
  "description": "My App",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

Step 5: Click Save Changes to save the file and then close the editor. 

I hope this will help all the node.js tester to start their first node.js application with their first hello world application for node.js.  

If you are looking for more hello world code for other programing languages please do have a look for Scripting “Hello World” in Different Programming Languages.

Please feel free to leave a comment below or if you have any other related queries. 

Facebook
Twitter
LinkedIn
Digg
Shashi kant Pandidhar

Shashi kant Pandidhar

I’ve been helping businesses to be online for over 15 years. Today my team and I, focus on helping real businesses to overcome real-life challenges and analyse data in a way that can help businesses grow in the right direction of this digital age.

Leave a Comment

Get the latest news and deals

Sign up for email updates covering blogs, offers, and lots more.

Current Deals at Netspace

Subscribe: Trusted By 1M+ Readers

Get the weekly Tech Update straight to your inbox.

WeCreativez WhatsApp Support
Our customer sales team is here to answer your questions. Ask us anything!
👋 Hi, how can I help?