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.
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.
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.
├── index.js
└── package.json
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:
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
| Code | Meaning |
|---|---|
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. |
req | The browser's incoming request. |
res | The 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 || 3000 | Use the hosting provider's assigned port, or 3000 when testing locally. |
listen(PORT) | Start accepting HTTP requests. |
Expected browser response:
3. Create package.json
Inside the same folder, create package.json. It tells GoDaddy how to build and start your app.
{
"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"
}
}nameandversionidentify your project.buildis required by GoDaddy's ZIP deployment. Our project needs no compilation, so it simply prints "build".startis the command GoDaddy uses to launch the app.enginesindicates 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.
package.json.4. Test on your own computer (optional)
Open a terminal inside the hello-world folder and run:
node --version
npm run build
npm startYou should see a message similar to:
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.
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
├── index.js
└── package.json
Common incorrect structure
└── 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
- Sign in to GoDaddy and open the hosting dashboard for your site.
- Find the Node.js Apps card — the one showing Add App.
- Click Add App. Enter an app name such as
hello-worldif asked. - Choose the option to upload source / ZIP (rather than GitHub). Select
hello-world.zip. - Let GoDaddy import the code, run the build command and deploy a private preview.
- Open the preview URL. Confirm you see the Hello World greeting.
- When satisfied, choose the Publish action. GoDaddy may ask you to attach an eligible hosting subscription and choose or attach a domain.
- Open the production URL and test it again.
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(...):
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.
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
- Beginner: Change the message to your own greeting. What changes in the browser?
- Observe: Why does the terminal print a different message from the browser?
- Think: What is the purpose of the
reqandresvariables? - Explore: Change the status code from
200to404. Use browser Developer Tools → Network to see what changed, then restore200. - 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.