ERR_MODULE_NOT_FOUND in production (Node v20) – Module exists locally but not found in Railway container

5 months ago

I'm deploying a Node.js application to Railway and getting the following error during startup:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/src/V1/App/Seeders/index.js' imported from /app/server.js
Node.js v20.20.0

The application starts with:

> node server.js

The import in server.js is:

import './src/V1/App/Seeders/index.js'

What I already verified

  • The file exists locally at:
src/V1/App/Seeders/index.js  
  • The folder name casing matches exactly (V1, App, Seeders)
  • I am using macOS locally
  • I understand Linux is case-sensitive and confirmed the casing matches
  • The project is plain JavaScript (not TypeScript)
  • Node version in production: v20.20.0

❓ What’s confusing

The module works locally but fails inside the Railway container with ERR_MODULE_NOT_FOUND.

Could this be:

  • A case-sensitivity issue that Git didn’t track correctly?
  • A file not committed?
  • A .gitignore issue?
  • A build vs runtime working directory issue?

📁 Project Structure (simplified)

server.js
src/
 └── V1/
      └── App/
           └── Seeders/
                └── index.js

Any guidance would be appreciated.

Solved$10 Bounty

Pinned Solution

5 months ago

No, I found that the error was directly from my tests; it had nothing to do with my configuration or case sensitivity. It was strange and difficult to find.

3 Replies

lu4p
FREE

5 months ago

Likely wrong casing in the import path as macos filesystem is case insensitive Linux is case sensitive.


saulosantiago
HOBBY

5 months ago

Are you using a monorepo? What are the settings that you are using on railway to build your app?


5 months ago

No, I found that the error was directly from my tests; it had nothing to do with my configuration or case sensitivity. It was strange and difficult to find.


Status changed to Solved brody 4 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...