Programmer's Picnic · Learn With Champak
Node.js on GoDaddy · Lesson 01 · 0 to Infinity

Your first live Node.js app:
Hello World

Write two tiny files, test on your computer, upload to GoDaddy's Node.js Apps, open a private preview and publish a live web server. No Express or database required.

Beginner20–30 minute activityNode.js 222 filesHands-on deployment

0. What are we building?

A website normally lives on a server. In this lesson, our JavaScript code becomes the server. Your browser sends a request; Node.js sends the text Hello World! back.

Browser → GoDaddy URL → Node.js app → Hello World!

By the end you should be able to explain the roles of index.js, package.json, process.env.PORT and the GoDaddy Preview / Publish steps.

Your GoDaddy screen shows Node.js Apps → Add App and 0/10 slots used. This guide follows that newer hosting product, not the older cPanel "Setup Node.js App" / Passenger interface.

1. Before you begin

  • Access to the GoDaddy hosting dashboard with the Add App button.
  • A plain-text editor such as VS Code or Notepad.
  • Optional: Node.js installed locally from nodejs.org if you want to test before uploading.
  • Ability to create a ZIP archive. We will place our two files at the root of the ZIP.
hello-world/
  ├── index.js
  └── package.json
Do not put passwords, API keys or database secrets inside your ZIP or GitHub repository. Use GoDaddy's application secrets / environment variable settings for those in later lessons.

2. Write Hello World in index.js

Create a folder called hello-world, and inside it create a file named index.js. Type or copy the following:

index.js
const http = require("http");

const server = http.createServer((req, res) => {
  res.writeHead(200, {
    "Content-Type": "text/plain; charset=utf-8"
  });
  res.end("Hello World! Welcome to Programmer's Picnic.");
});

const PORT = process.env.PORT || 3000;

server.listen(PORT, () => {
  console.log("Server started on port " + PORT);
});

Understand the program line by line

CodeMeaning
require("http")Use Node.js's built-in HTTP module. Nothing needs to be installed with npm.
createServer(...)Create a server and a function to handle every incoming request.
reqThe browser's incoming request.
resThe response your server sends back to the browser.
writeHead(200,...)Indicate success and send plain text with UTF-8 encoding.
res.end(...)Finish the HTTP response and send the greeting.
process.env.PORT || 3000Use the hosting provider's assigned port, or 3000 when testing locally.
listen(PORT)Start accepting HTTP requests.

Expected browser response:

Hello World! Welcome to Programmer's Picnic.
✎ Open our code editor to study JavaScript syntax. Note: an ordinary browser editor cannot host a persistent Node.js server; run this example in Node.js or on GoDaddy.

3. Create package.json

Inside the same folder, create package.json. It tells GoDaddy how to build and start your app.

package.json
{
  "name": "godaddy-hello-world",
  "version": "1.0.0",
  "private": true,
  "description": "Beginner Node.js HTTP server for GoDaddy hosting",
  "main": "index.js",
  "engines": {
    "node": "22.x"
  },
  "scripts": {
    "build": "echo build",
    "start": "node index.js"
  }
}
  • name and version identify your project.
  • build is required by GoDaddy's ZIP deployment. Our project needs no compilation, so it simply prints "build".
  • start is the command GoDaddy uses to launch the app.
  • engines indicates the Node.js version compatible with this example.

No npm install is necessary for this Hello World project because http is built into Node.js.

✎ Open our code editor for practice reading JSON, then save the file locally as package.json.

4. Test on your own computer (optional)

Open a terminal inside the hello-world folder and run:

Terminal
node --version
npm run build
npm start

You should see a message similar to:

Server started on port 3000

Open http://localhost:3000/ on the same computer. You should see the Hello World greeting. Press Ctrl + C in the terminal to stop the server.

If node is not recognised, install Node.js locally or skip directly to the GoDaddy upload. The local test is optional.

5. Create the ZIP correctly

Select the two files index.js and package.json, then compress them into hello-world.zip. On Windows, select both files, right-click and choose Compress to ZIP file (wording may vary).

Correct ZIP structure

hello-world.zip
  ├── index.js
  └── package.json

Common incorrect structure

hello-world.zip
  └── hello-world/
      ├── index.js
      └── package.json

When you open the ZIP, you should be able to see package.json immediately. This matters because GoDaddy expects it at the archive's root.

You can compare your files with our complete starter source on GitHub.

6. Upload to GoDaddy Node.js Apps

  1. Sign in to GoDaddy and open the hosting dashboard for your site.
  2. Find the Node.js Apps card — the one showing Add App.
  3. Click Add App. Enter an app name such as hello-world if asked.
  4. Choose the option to upload source / ZIP (rather than GitHub). Select hello-world.zip.
  5. Let GoDaddy import the code, run the build command and deploy a private preview.
  6. Open the preview URL. Confirm you see the Hello World greeting.
  7. When satisfied, choose the Publish action. GoDaddy may ask you to attach an eligible hosting subscription and choose or attach a domain.
  8. Open the production URL and test it again.
Important distinction: A private preview is not the same as a publicly available website. The exact control labels may differ as GoDaddy updates its dashboard. Use the upload → preview → publish flow shown by your app interface.

Which address will you use? Use the real preview/published URL shown by GoDaddy. The screenshot establishes the hosting account's domain, but it does not establish the URL that GoDaddy will assign to this specific app, so do not guess it.

Official documentation: GoDaddy Node.js Hosting · Application file requirements.

7. Make a change and deploy again

Change the text inside res.end(...):

Replace this one line in index.js
res.end("Hello from my first GoDaddy Node.js server!");

Save the file, create a fresh ZIP containing both files, upload the new version, check the preview and publish the new deployment. Refresh the published page and make sure your new message appears.

Editing a local file does not automatically change a deployed ZIP app. An updated upload and deployment is required. A GitHub-connected app can use a different deployment workflow.
✎ Practice changing the greeting in our editor, then apply the change in your real index.js.

8. Problems and quick fixes

Build says package.json is missing

Open your ZIP. package.json must be at the top level, not inside an extra folder. Confirm the filename does not end in .txt.

The app imports but does not start

Confirm scripts.start is node index.js, the file is named index.js, and the code has no syntax errors. Review the build and runtime logs supplied by GoDaddy.

Port or health check error

Use const PORT = process.env.PORT || 3000;. Do not hardcode a production port. Make sure server.listen(PORT) runs when the app starts.

The app works on my laptop but not in preview

Confirm both files are included, the correct version was uploaded, and there are no local-only file paths or missing dependencies. Check deployment logs.

I see the old greeting after changing the code

Verify that a new ZIP was uploaded and a new preview deployed, then publish the new version. Refresh the browser after production deployment completes.

I can preview but the public URL does not work

Check whether the app is published, attached to an eligible hosting plan and mapped to the intended domain. A private preview alone does not make the site public.

Do I need Express or a database now?

No. This first lesson uses the built-in HTTP module only. Express, route handling, forms, APIs and MySQL come later.

9. Your turn — exercises

  1. Beginner: Change the message to your own greeting. What changes in the browser?
  2. Observe: Why does the terminal print a different message from the browser?
  3. Think: What is the purpose of the req and res variables?
  4. Explore: Change the status code from 200 to 404. Use browser Developer Tools → Network to see what changed, then restore 200.
  5. Deploy: Publish a revised version after successfully testing it in private preview.

Knowledge check

Q1. Which file contains the server program?

index.js.

Q2. Which file tells GoDaddy how to start the app?

package.json, specifically its scripts.start entry.

Q3. Why use process.env.PORT?

So the server listens on the port assigned by the hosting environment rather than assuming a fixed production port.

Q4. Does a working private preview mean everyone can visit the app?

No. You must publish it and configure any required hosting subscription / domain association.

10. What comes next?

You now have a Node.js server that replies to a browser request. The next logical lesson is Node.js on GoDaddy — Lesson 2: Routes and JSON: responding differently to /, /about and /api/hello. After that: Express, HTML forms, MySQL and a small practical project.

↑ Top