marktawa
HOBBYOP
a year ago
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);Railway Project ID: 6f6c6ce8-b285-491b-abd2-8358475e2a5c
2 Replies
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
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"
}
}