5 days ago
We are attempting to set this up on Claude and we get stuck right away as we are brand new to railway and setting this up. Looking for someone to work with us to to help get this running.
Attachments
1 Replies
5 days ago
Hey.
typescript
is a devDependency in your package.json. In your Dockerfile, you have npm ci --only=production
. This means only production packages are installed at this stage (so only the packages in dependencies
in your package.json).
tsc
is something you can call if you got typescript
package installed. But since you do not have that package installed (due to --only=production
), it cannot be found later in the Dockerfile when you do RUN npm run build
.
You can see that if you look at your error, it says: tsc: not found
.
Hopefully this helps :)
EDIT: just so you have some solution as well. You have multiple options. These are two of them:
1. Install all packages before build:
# Use Node.js 18 LTS
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including devDependencies) for the build
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Prune devDependencies for a smaller production image (optional but good practice)
# You could alternatively use a multi-stage build for a cleaner separation
RUN npm prune --production
# Expose the port
EXPOSE 8000
# Set environment to production
ENV NODE_ENV=production
# Start the HTTP server
CMD ["npm", "start"]
multi-stage build (or similar, change it as you need):
# --- Build Stage ---
FROM node:18-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies for the build
RUN npm ci
# Copy source code
COPY . .
# Build the application
RUN npm run build
# --- Production Stage ---
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy package.json for production dependencies
COPY package*.json ./
# Install only production dependencies
RUN npm ci --only=production
# Copy built artifacts from the builder stage
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/README.md ./README.md
# Add any other necessary files, e.g., static assets, if not in dist
# Expose the port
EXPOSE 8000
# Set environment to production
ENV NODE_ENV=production
# Start the HTTP server
CMD ["npm", "start"]