Deploy Barebones Node.js
marktawa
HOBBYOP

2 years 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

Closed

2 Replies

maddsua
HOBBY

2 years 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


marktawa
HOBBYOP

2 years 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"
    }
}

Welcome!

Sign in to your Railway account to join the conversation.

Loading...