Deploy with Node js, express y mongoose

Oct 31 11:07:12 AM ==> Running ‘node app.js’
Oct 31 11:07:14 AM node:internal/modules/cjs/loader:1078
Oct 31 11:07:14 AM throw err;
Oct 31 11:07:14 AM ^
Oct 31 11:07:14 AM
Oct 31 11:07:14 AM Error: Cannot find module ‘…/models/User’
Oct 31 11:07:14 AM Require stack:
Oct 31 11:07:14 AM - /opt/render/project/src/controllers/authControllers.js
Oct 31 11:07:14 AM - /opt/render/project/src/routes/authRoutes.js
Oct 31 11:07:14 AM - /opt/render/project/src/app.js
Oct 31 11:07:14 AM at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
Oct 31 11:07:14 AM at Module._load (node:internal/modules/cjs/loader:920:27)
Oct 31 11:07:14 AM at Module.require (node:internal/modules/cjs/loader:1141:19)
Oct 31 11:07:14 AM at require (node:internal/modules/cjs/helpers:110:18)
Oct 31 11:07:14 AM at Object. (/opt/render/project/src/controllers/authControllers.js:1:13)
Oct 31 11:07:14 AM at Module._compile (node:internal/modules/cjs/loader:1254:14)
Oct 31 11:07:14 AM at Module._extensions…js (node:internal/modules/cjs/loader:1308:10)
Oct 31 11:07:14 AM at Module.load (node:internal/modules/cjs/loader:1117:32)
Oct 31 11:07:14 AM at Module._load (node:internal/modules/cjs/loader:958:12)
Oct 31 11:07:14 AM at Module.require (node:internal/modules/cjs/loader:1141:19) {
Oct 31 11:07:14 AM code: ‘MODULE_NOT_FOUND’,
Oct 31 11:07:14 AM requireStack: [
Oct 31 11:07:14 AM ‘/opt/render/project/src/controllers/authControllers.js’,
Oct 31 11:07:14 AM ‘/opt/render/project/src/routes/authRoutes.js’,
Oct 31 11:07:14 AM ‘/opt/render/project/src/app.js’
Oct 31 11:07:14 AM ]
Oct 31 11:07:14 AM }
Oct 31 11:07:14 AM
Oct 31 11:07:14 AM Node.js v18.16.0

Hi,

I suspect this may be a filename casing issue. Render uses Linux with a case-sensitive filesystem.

If …/models/User is actually …/models/user (or other casing variant) it won’t be found. Ensure the casing is the same in your code as well as your repo.

Alan

Hello Alan, thank you very much for responding. The file path is …/models/User, ‘User’ is capitalized because it refers to the collection in my database, and it’s also spelled this way in my GitHub repository. Do you recommend that I change all my code and rewrite it in lowercase?"

They can be whichever casing you want, the code & the filesystem just need to match.

Alan

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