8 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?
23 Replies
8 months ago
Hey, what kind of code are you trying to deploy? NodeJS?
8 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"
}8 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
This is an existing application that I forked.. not sure those solutions will work
8 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?
8 months ago
Go to your service settings, scroll down until you find "start command", and provide the following value: node dist/app.mjs
8 months ago
If that doesn't work, we can try another command
8 months ago
Oh then try to specify it via environment variable, set the following on your service:
RAILPACK_START_CMD=node dist/app.jsand 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
8 months ago
give me a minute, I'm looking at the code.
8 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.
8 months ago
anyway, i'll see i can find other ways around it
Thanks, I appreciate that. Can you share what you did to get it working?
8 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 dev8 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
