Error: Cannot find module '../routes' .

yajindragautam
FREE

6 months ago

Hi, I am trying to host express js app. But during deployment I am getting this error. There is a index.js file in routes folder. But it is not fetching that file. Please help me solve this error. In my local it working fine.

The error is coming from this line of code:.
require('../routes')(app, passport);

Error: Cannot find module '../routes'

Require stack:

  • /app/src/loaders/express.js

  • /app/src/loaders/index.js

  • /app/src/server.js

  • /app/src/app.js

    at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)

    at Module._load (node:internal/modules/cjs/loader:981:27)

    at Module.require (node:internal/modules/cjs/loader:1231:19)

    at require (node:internal/modules/helpers:177:18)

    at expressLoader.init (/app/src/loaders/express.js:78:5)

    at Object.init (/app/src/loaders/index.js:7:25)

    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {

    code: 'MODULENOTFOUND',

    requireStack: [

    '/app/src/loaders/express.js',

    '/app/src/loaders/index.js',

    '/app/src/server.js',

    '/app/src/app.js'

    ]

}

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

Solved

7 Replies

6 months ago

Hello,

The folder is named Routes with a capital R - not routes with a lowercase r

Best,
Brody


brody

Hello,The folder is named Routes with a capital R - not routes with a lowercase rBest,Brody

yajindragautam
FREE

6 months ago

Hi

But my folder name is not Routes it is routes . Bellow is the SC.

Attachments


6 months ago

In GitHub it is Routes


yajindragautam
FREE

6 months ago

Thank you so much.

But how could that happen in my VS code the routes is named with small r but I pushed the same code to github

there is Capital R.


6 months ago

You had it Routes locally at one point, but since GitHub does not sync file and folder name casing, whenever you changed it to routes the name wasn't updated in GitHub.


yajindragautam
FREE

6 months ago

It could be. Thank you so much .


6 months ago

No problem!


Status changed to Solved brody 6 months ago


Error: Cannot find module '../routes' . - Railway Help Station