Help getting application running
mparisi76
HOBBYOP

9 months ago

I'm a software engineer and new to Railway but not much of an infra guy.. I'm trying to get an application running but having trouble. First off, the package.json does not have a start script. I'm not sure what that should be.. Can someone here help?

$10 Bounty

23 Replies

mparisi76
HOBBYOP

9 months ago

eff4fdbb-16e0-4ffb-bee2-4ad13f2f307e


9 months ago

Hey, what kind of code are you trying to deploy? NodeJS?


mparisi76
HOBBYOP

9 months ago

Hi, yes node


9 months ago

then basically in your package.json under scripts simply specify a command to start your application, for example:

"scripts": {
  "start": "node dist/server.js"
}

9 months ago

you're also able to specify a start command directly on Railway without touching code, in case you want that let me know


mparisi76
HOBBYOP

9 months ago

This is an existing application that I forked.. not sure those solutions will work


9 months ago

if you do not know the start command then I really can't help much without it.
Do you have the application repository?


mparisi76
HOBBYOP

9 months ago


9 months ago

Go to your service settings, scroll down until you find "start command", and provide the following value: node dist/app.mjs


9 months ago

If that doesn't work, we can try another command


mparisi76
HOBBYOP

9 months ago

I did try node dist/app.js and that didn't work, but I'll try yours


9 months ago

Oh then try to specify it via environment variable, set the following on your service:

RAILPACK_START_CMD=node dist/app.js

mparisi76
HOBBYOP

9 months ago

with node dist/app.mjs the deployment finishes, but then it crashes


mparisi76
HOBBYOP

9 months ago

and I see a bunch of these:Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/node_modules/lodash/debounce' imported from /app/dist/app.mjs


9 months ago

give me a minute, I'm looking at the code.


9 months ago

hey, I struggled a little bit on trying to run it and I got it running by following the instructions but I feel like it's wrong…
the project is saying to run it on development mode which is a bit weird.


9 months ago

anyway, i'll see i can find other ways around it


mparisi76
HOBBYOP

9 months ago

Thanks, I appreciate that. Can you share what you did to get it working?


9 months ago

hey, i've used a Dockerfile to get it working, it runs on development mode, I would not use it in any way.

FROM node:22.16.0-alpine

WORKDIR /app

COPY yarn.lock package.json .

RUN npm install

COPY . .

RUN npm run build

CMD npm run dev

mparisi76
HOBBYOP

9 months ago

How do I use the Docker file within Railway?


9 months ago

How do I use the Docker file within Railway?

I think you need to have a Dockerfile at the root of the project OR point the service settings to Dockerfile path

Attachments


mparisi76
HOBBYOP

9 months ago


mparisi76
HOBBYOP

9 months ago

!s


Loading...