Getting Module Not Found

while deploying the Node.js backend app i got this error
but my localhost is working absolutely without any warnings and errors.

Error: Cannot find module ‘…/utils/AppError’
Jul 6 06:24:26 PM Require stack:
Jul 6 06:24:26 PM - /opt/render/project/src/controller/globalController.js
Jul 6 06:24:26 PM - /opt/render/project/src/controller/postController.js
Jul 6 06:24:26 PM - /opt/render/project/src/routes/postRoutes.js
Jul 6 06:24:26 PM - /opt/render/project/src/app.js
Jul 6 06:24:26 PM - /opt/render/project/src/server.js
Jul 6 06:24:26 PM at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
Jul 6 06:24:26 PM at Function.Module._load (node:internal/modules/cjs/loader:778:27)
Jul 6 06:24:26 PM at Module.require (node:internal/modules/cjs/loader:1005:19)
Jul 6 06:24:26 PM at require (node:internal/modules/cjs/helpers:102:18)
Jul 6 06:24:26 PM at Object. (/opt/render/project/src/controller/globalController.js:2:18)
Jul 6 06:24:26 PM at Module._compile (node:internal/modules/cjs/loader:1103:14)
Jul 6 06:24:26 PM at Object.Module._extensions…js (node:internal/modules/cjs/loader:1157:10)
Jul 6 06:24:26 PM at Module.load (node:internal/modules/cjs/loader:981:32)
Jul 6 06:24:26 PM at Function.Module._load (node:internal/modules/cjs/loader:822:12)
Jul 6 06:24:26 PM at Module.require (node:internal/modules/cjs/loader:1005:19)
Jul 6 06:24:26 PM at require (node:internal/modules/cjs/helpers:102:18)
Jul 6 06:24:26 PM at Object. (/opt/render/project/src/controller/postController.js:2:26)
Jul 6 06:24:26 PM at Module._compile (node:internal/modules/cjs/loader:1103:14)
Jul 6 06:24:26 PM at Object.Module._extensions…js (node:internal/modules/cjs/loader:1157:10)
Jul 6 06:24:26 PM at Module.load (node:internal/modules/cjs/loader:981:32)
Jul 6 06:24:26 PM at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
Jul 6 06:24:26 PM code: ‘MODULE_NOT_FOUND’,

Hi there,

Check the casing of the file/folder in the repo for:

const AppError = require(‘…/utils/AppError’);

it could be that the folder/filename is using a different casing than the require, and because we are using Linux, which is a case-sensitive file system, it would fail with this error on us and work for you where you are probably using a case-insensitive file system

Regards,

John B
Render Support, UTC+1 :uk:

1 Like

Thank You so much … somehow the file name was different on the repo

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