10 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
expressdependency is correctly listed in mypackage.jsonand 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_modulesfolder,package.json, andyarn.lockto 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
expressis listed as a dependency in mypackage.jsonfile.I have tried regenerating my
yarn.lockfile 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 • 10 months ago
Status changed to Closed brody • 10 months ago
