Error: Cannot find module (User.js)

Hi,

I’m trying to deploy my project but facing errors, these are the errors:
throw err;
Error: Cannot find module ‘…/models/User.js’

I checked that ‘…/models/User.js’ is the correct route and that it’s User.js and not user.js both in github and locally. and it its.

I would love some help.

complete log:

Apr 26 12:40:41 AM> expresstracker-backend@1.0.0 start

Apr 26 12:40:41 AM> npm install && node app.js

Apr 26 12:40:41 AM

Apr 26 12:40:47 AM

Apr 26 12:40:47 AMup to date, audited 161 packages in 4s

Apr 26 12:40:47 AM

Apr 26 12:40:47 AM17 packages are looking for funding

Apr 26 12:40:47 AM run npm fund for details

Apr 26 12:40:47 AM

Apr 26 12:40:47 AMfound 0 vulnerabilities

Apr 26 12:40:49 AMnode:internal/modules/cjs/loader:1146

Apr 26 12:40:49 AM throw err;

Apr 26 12:40:49 AM ^

Apr 26 12:40:49 AM

Apr 26 12:40:49 AMError: Cannot find module ‘…/models/User.js’

Apr 26 12:40:49 AMRequire stack:

Apr 26 12:40:49 AM- /opt/render/project/src/controllers/user.js

Apr 26 12:40:49 AM- /opt/render/project/src/routes/users.js

Apr 26 12:40:49 AM- /opt/render/project/src/app.js

Apr 26 12:40:49 AM at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)

Apr 26 12:40:49 AM at Module._load (node:internal/modules/cjs/loader:984:27)

Apr 26 12:40:49 AM at Module.require (node:internal/modules/cjs/loader:1231:19)

Apr 26 12:40:49 AM at require (node:internal/modules/helpers:179:18)

Apr 26 12:40:49 AM at Object. (/opt/render/project/src/controllers/user.js:1:14)

Apr 26 12:40:49 AM at Module._compile (node:internal/modules/cjs/loader:1369:14)

Apr 26 12:40:49 AM at Module._extensions…js (node:internal/modules/cjs/loader:1427:10)

Apr 26 12:40:49 AM at Module.load (node:internal/modules/cjs/loader:1206:32)

Apr 26 12:40:49 AM at Module._load (node:internal/modules/cjs/loader:1022:12)

Apr 26 12:40:49 AM at Module.require (node:internal/modules/cjs/loader:1231:19) {

Apr 26 12:40:49 AM code: ‘MODULE_NOT_FOUND’,

Apr 26 12:40:49 AM requireStack: [

Apr 26 12:40:49 AM ‘/opt/render/project/src/controllers/user.js’,

Apr 26 12:40:49 AM ‘/opt/render/project/src/routes/users.js’,

Apr 26 12:40:49 AM ‘/opt/render/project/src/app.js’

Apr 26 12:40:49 AM ]

Apr 26 12:40:49 AM}

Apr 26 12:40:49 AM

Apr 26 12:40:49 AMNode.js v20.12.2

Hi there,

I see an upper case U in ‘…/models/User.js’ - can you confirm that’s how your file is named?

Regards,

Matt

Hi,

The file name was ‘…/models/users.js’, I changed it to: ‘…/models/Users.js’.
but there is the same error again.

Bes Regards, Tal.

throw err;

Apr 26 11:34:50 AM ^

Apr 26 11:34:50 AM

Apr 26 11:34:50 AMError: Cannot find module ‘…/models/User.js’

Apr 26 11:34:50 AMRequire stack:

Apr 26 11:34:50 AM- /opt/render/project/src/controllers/user.js

Apr 26 11:34:50 AM- /opt/render/project/src/routes/users.js

Apr 26 11:34:50 AM- /opt/render/project/src/app.js

Hi there,

I’m guessing this will have something to do with your directory structure. Is the Github repo public? Or could you share a screenshot of where your models and controllers are.

If you’d prefer not to do this in the public forum, feel free to open a support ticket.

Regards,

Matt

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