0

I fixed it, I added a comment below.

I have been following this mdn tutorial: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/deployment

And I am just in the part of deploying the app, so I used Railway as the tutorial says, the code works well in the localhost, it does not display any error, but once is deployed and running in Railway it displays this error in the deploy log:

`> express-locallibrary-tutorial@0.0.0 start
> node ./bin/www
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module '../models/bookinstance'
Require stack:
- /app/controllers/bookController.js
- /app/routes/catalog.js
- /app/app.js
- /app/bin/www
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/app/controllers/bookController.js:4:22)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/app/controllers/bookController.js',
'/app/routes/catalog.js',
'/app/app.js',
'/app/bin/www'
]
}
Node.js v18.12.1
npm WARN config production Use `--omit=dev` instead.`

This is the code I am deploying is this one: https://github.com/DavitBoo/express-locallibrary-tutorial

I also tried to deploy it using render for example and I got the same output. I was checking some similar stackoverflow posts, like this one: node:internal/modules/cjs/loader:998 throw err; ^ Cannot find solution to this error

But I could not implement a solution, a thing I was thinking is why the routes show this '/app/' in the error, like here:

`- /app/controllers/bookController.js

  • /app/routes/catalog.js
  • /app/app.js
  • /app/bin/www`
  • I fixed it, for some reason I had this "bookinstance" and even if it was in the whole code using this lowercase, I changed in the whole project to camelcase and now it works. – DavidMarras Aug 16 '23 at 11:21

0 Answers0