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

21 days 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'

white_check_mark emoji 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

question emoji 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?

file_folder emoji Project Structure (simplified)

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

Any guidance would be appreciated.

Solved$10 Bounty

Pinned Solution

ruvalcaba18
FREEOP

21 days 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
FREETop 5% Contributor

21 days ago

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


saulosantiago
HOBBY

21 days ago

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


ruvalcaba18
FREEOP

21 days 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 15 days ago


Loading...