5 hours ago
Hello Railway Support Team!
I'm trying to deploy my Node.js AI Telegram bot using Railway and GitHub.
My project details:
- Service: observant-insight
-
- GitHub repository: Rush226/Sirius-AI
-
- Branch: main
-
- Node.js version: 20.20.2
The build completes successfully, but the deployment crashes with this error:
Error: Cannot find module '/app/server.js'
code: MODULE_NOT_FOUND
I have checked my package.json and configured the start command as node server.js.
Could you please help me identify why Railway cannot find server.js and how I can fix this deployment issue?
Thank you for your time and assistance!
4 Replies
5 hours ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • about 5 hours ago
5 hours ago
! Cannot find module '/app/server.js' means Railway can't find server.js at the root of the built image. A few things to check:
File location: make sure server.js is at the repo root on GitHub. If it's in a subfolder (e.g. src/), either set Root Directory in Settings → Source, or change the start command to node src/server.js.
Filename case: Linux is case-sensitive, so Server.js ≠ server.js. This works locally on Windows/Mac but fails on Railway.
Not committed: check that the file isn't in .gitignore and that it's actually pushed to the main branch.
Actual entry file: if your entry point is index.js or bot.js, the start command must match it.
Dockerfile: if you have one, check that WORKDIR and COPY are correct.
Also confirm your package.json has "scripts": { "start": "node server.js" }. If it still fails, please share your repo file tree and the full deploy logs so we can pinpoint it.
roobinhood1000
! Cannot find module '/app/server.js' means Railway can't find server.js at the root of the built image. A few things to check: File location: make sure server.js is at the repo root on GitHub. If it's in a subfolder (e.g. src/), either set Root Directory in Settings → Source, or change the start command to node src/server.js. Filename case: Linux is case-sensitive, so Server.js ≠ server.js. This works locally on Windows/Mac but fails on Railway. Not committed: check that the file isn't in .gitignore and that it's actually pushed to the main branch. Actual entry file: if your entry point is index.js or bot.js, the start command must match it. Dockerfile: if you have one, check that WORKDIR and COPY are correct. Also confirm your package.json has "scripts": { "start": "node server.js" }. If it still fails, please share your repo file tree and the full deploy logs so we can pinpoint it.
5 hours ago
Hello! Thank you for your response!
I've already checked most of these points:
- server.js is located in the repository root.
-
- package.json is also in the root directory.
-
- The production branch is main.
-
- Railway Root Directory is set to /.
-
- The start command is node server.js.
-
- The package.json contains the correct start script.
However, Railway still reports:
Cannot find module '/app/server.js'
Could you please help me investigate why the file is missing from the deployed environment despite these configurations?
Thank you!
4 hours ago
If server.js is at the root, the branch is main, and the start command is correct, the likely causes are:
A nested folder on GitHub. This is the most common one: the project was uploaded as a zip or folder, so GitHub's root contains Sirius-AI-main/server.js, not server.js.
A hidden filename problem. It could be server.js.txt, Server.js, or server.js with a trailing space, which Windows often hides.
A Dockerfile or .dockerignore. A Dockerfile in the repo overrides Nixpacks. A bad COPY or WORKDIR, or a .dockerignore excluding the file, would produce this exact error.
The wrong source or commit. The service may point at another repo or branch, or deploy an older commit made before server.js was pushed.
The decisive test: temporarily set the Railway start command to ls -la /app && node server.js. The deploy logs will then show exactly what's in /app, which turns the guess into a fact.
Here is a comment you can paste:
Thanks for checking those. To narrow it down: (1) on GitHub's web UI, open the repo root and confirm server.js is listed there directly, with exact lowercase spelling and no nested folder; (2) check for a Dockerfile or .dockerignore in the repo, since a Dockerfile overrides Nixpacks; (3) in Settings → Source, confirm the repo and branch, and check that the deployed commit hash matches your latest push; (4) temporarily set the start command to ls -la /app && node server.js and share the output, which will show what actually exists in /app. Please also post the build logs, especially the "Detected Node" or COPY step.
If you paste the repo's file list or the ls output, I can narrow it to one cause.
roobinhood1000
If server.js is at the root, the branch is main, and the start command is correct, the likely causes are: A nested folder on GitHub. This is the most common one: the project was uploaded as a zip or folder, so GitHub's root contains Sirius-AI-main/server.js, not server.js. A hidden filename problem. It could be server.js.txt, Server.js, or server.js with a trailing space, which Windows often hides. A Dockerfile or .dockerignore. A Dockerfile in the repo overrides Nixpacks. A bad COPY or WORKDIR, or a .dockerignore excluding the file, would produce this exact error. The wrong source or commit. The service may point at another repo or branch, or deploy an older commit made before server.js was pushed. The decisive test: temporarily set the Railway start command to ls -la /app && node server.js. The deploy logs will then show exactly what's in /app, which turns the guess into a fact. Here is a comment you can paste: Thanks for checking those. To narrow it down: (1) on GitHub's web UI, open the repo root and confirm server.js is listed there directly, with exact lowercase spelling and no nested folder; (2) check for a Dockerfile or .dockerignore in the repo, since a Dockerfile overrides Nixpacks; (3) in Settings → Source, confirm the repo and branch, and check that the deployed commit hash matches your latest push; (4) temporarily set the start command to ls -la /app && node server.js and share the output, which will show what actually exists in /app. Please also post the build logs, especially the "Detected Node" or COPY step. If you paste the repo's file list or the ls output, I can narrow it to one cause.
3 hours ago
Hello!
Thank you for your assistance!
I managed to resolve the deployment issue. The problem was caused by an incorrectly named file (server.js. instead of server.js).
I corrected the filename, updated the project, and successfully deployed the service.
The service is now showing Active.
I really appreciate your help and patience!
Best regards.