Node.js app requirements
View as MarkdownThe structure and configuration a Node.js app must have before uploading to GoDaddy Hosting.
Overview
This page describes the structure your Node.js app must have before you upload it to GoDaddy Hosting. An app that skips any of these requirements fails at build or startup when you publish.
Go to How to deploy your Node.js app for the full deployment walkthrough.
package.json
The zip must contain a package.json at the root. It must include non-empty name and version fields. The main field is optional but recommended when your entry point differs from index.js.
Specifying a Node.js version is also recommended:
{
"name": "my-app",
"version": "1.0.0",
"engines": {
"node": "20.x"
}
}Scripts
package.json must define both a build script and a start script.
Build script: The platform runs npm run build during deployment. If your app has no compile step, define a no-op placeholder:
"build": "echo build"Frameworks (Next.js, NestJS, TypeScript projects) need a real build command.
Start script: The platform starts your app with npm start. The command must point to a file that exists in the zip:
"start": "node index.js"A complete minimal package.json:
{
"name": "my-app",
"version": "1.0.0",
"engines": {
"node": "20.x"
},
"scripts": {
"build": "echo build",
"start": "node index.js"
}
}Port binding
Your app must listen on the port the platform assigns. Read it from process.env.PORT:
const port = process.env.PORT || 3000;
server.listen(port);The platform sets PORT at runtime. An app that binds to a hardcoded port won't receive traffic.
Dependencies
Every package the app needs at runtime must be in dependencies, not devDependencies. The platform installs only dependencies before running build and start.
{
"dependencies": {
"express": "^4.18.0"
},
"devDependencies": {
"jest": "^29.0.0"
}
}A runtime package left in devDependencies causes MODULE_NOT_FOUND errors at startup.
Zip contents
Include source files and package.json, but exclude node_modules. The platform runs npm install after extracting the zip.
Files to include and exclude:
| Include | Exclude |
|---|---|
package.json, package-lock.json | node_modules/ |
| All source files | .env files with secrets |
| Static assets | Uncommitted build artifacts |
Including node_modules in the zip slows upload and might conflict with the platform install.
Related
Concepts
Last updated on
How is this guide?