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

Hello, I’m trying to deploy my backend but I’m getting this error

Error: Cannot find module ‘./routes/videoGamesRouter.js’
Sep 12 04:19:39 PM Require stack:
Sep 12 04:19:39 PM - /opt/render/project/src/api/src/app.js
Sep 12 04:19:39 PM - /opt/render/project/src/api/index.js
Sep 12 04:19:39 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
Sep 12 04:19:39 PM at Function.Module._load (internal/modules/cjs/loader.js:841:27)
Sep 12 04:19:39 PM at Module.require (internal/modules/cjs/loader.js:1025:19)
Sep 12 04:19:39 PM at require (internal/modules/cjs/helpers.js:72:18)
Sep 12 04:19:39 PM at Object. (/opt/render/project/src/api/src/app.js:7:27)
Sep 12 04:19:39 PM at Module._compile (internal/modules/cjs/loader.js:1137:30)
Sep 12 04:19:39 PM at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10)
Sep 12 04:19:39 PM at Module.load (internal/modules/cjs/loader.js:985:32)
Sep 12 04:19:39 PM at Function.Module._load (internal/modules/cjs/loader.js:878:14)
Sep 12 04:19:39 PM at Module.require (internal/modules/cjs/loader.js:1025:19) {
Sep 12 04:19:39 PM code: ‘MODULE_NOT_FOUND’,
Sep 12 04:19:39 PM requireStack: [
Sep 12 04:19:39 PM ‘/opt/render/project/src/api/src/app.js’,
Sep 12 04:19:39 PM ‘/opt/render/project/src/api/index.js’
Sep 12 04:19:39 PM ]
Sep 12 04:19:39 PM }

My server is working correctly locally

Jonnier,

If something works locally and it doesn’t work when deployed to us then that suggests that the two environments are different - well, we can be sure that are!

When paths are involved like this, my immediate thought is filename/folder casing. We run a case-sensitive file system, but you are probably using a case-insensitive file system.

From your error here:

Error: Cannot find module ‘./routes/videoGamesRouter.js’

I would check that the names of the folder and files on disk/in your GitHub repo match exactly the same as the import used in your code, if not, you can either rename the file or change the import so it matches,

I hope that helps,

John B
Render Support, UTC+1 :uk:

thank you very much, the file name was the problem

no problem, catches us all out…once :slight_smile:

John B
Render Support, UTC+1 :uk:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.