Deploy Barebones Node.js

How do I deploy a barebones Node.js app? I'm getting a build error Nixpacks build failed. For this file, no build command is required. Only a start command node index.js and the port 8080. It's just one file in a repo index.js. It has the following contents:
const http = require('http');

const server = http.createServer((req, res) => {
res.setHeader('Content-Type', 'text/html');
res.end('<h1>Hello World!</h1>');
});

server.listen(8080);
const http = require('http');

const server = http.createServer((req, res) => {
res.setHeader('Content-Type', 'text/html');
res.end('<h1>Hello World!</h1>');
});

server.listen(8080);
Railway Project ID: 6f6c6ce8-b285-491b-abd2-8358475e2a5c
3 Replies
Percy
Percy2mo ago
Project ID: 6f6c6ce8-b285-491b-abd2-8358475e2a5c
maddsua
maddsua2mo ago
Nixpacks builds a docker image from ur source code that's then is getting pushed to railway registry and is ran as a service. So there's always this build step when deploying code. If you provide a more detailed error, we could try to debug that
markmunyaka
markmunyakaOP2mo ago
SOLVED Thanks for the tip. I solved the issue by adding a package.json file to my repo. I think it helped Nixpacks build the image.
{
"scripts": {
"start": "node index.js"
}
}
{
"scripts": {
"start": "node index.js"
}
}
Want results from more Discord servers?
Add your server