3 months ago
I'm getting this deploy crash. Any idea about what might be happening?Error: Cannot find module 'express' Require stack: - /app/dist/index.js ... (rest of stack trace)
Here's a summary of the problem and the troubleshooting steps I've already taken:
Intermittent Nature: The error does not occur consistently. Sometimes the deployment succeeds, and sometimes it fails with this "Cannot find module 'express'" error.
Local Docker Build: My local Docker builds are successful. The application runs correctly when built and run locally using Docker. This indicates that the
express
dependency is correctly listed in mypackage.json
and installed during the Docker build process.Dockerfile: I am using a multi-stage Docker build. I install all dependencies in the build stage and then copy the
node_modules
folder,package.json
, andyarn.lock
to the runtime stage. I then install only production dependencies in the runtime stage usingyarn install --production
.Dependency Management: I am using Yarn 4 for dependency management.
Troubleshooting Steps:
I have tried clearing the build cache on Railway by making small, insignificant changes to my code and redeploying. This sometimes works, but the issue recurs.
I have verified that
express
is listed as a dependency in mypackage.json
file.I have tried regenerating my
yarn.lock
file locally and committing the changes.I have tried rebuilding the Docker image locally multiple times.
I have tried different variations of my Dockerfile (including installing dependencies in the runtime stage). However, these changes have either broken my local build or not resolved the issue on Railway.
2 Replies
Status changed to Awaiting User Response railway[bot] • 3 months ago
Status changed to Closed brody • 3 months ago