Problem when deploying the vidly app on heroku

Hi. I’m currently at the end of the nodejs course, but im having problem with some dependencies. Im having a lot of missing module errors on my error stack trace.

This is the logs im getting:

“2020-11-28T20:34:25.614845+00:00 app[web.1]: > project-vidly@1.0.0 start /app
2020-11-28T20:34:25.614845+00:00 app[web.1]: > node index.js
2020-11-28T20:34:25.614846+00:00 app[web.1]:
2020-11-28T20:34:26.999600+00:00 app[web.1]: {“error”:{“code”:“MODULE_NOT_FOUND”,“requireStack”:[”/app/routes/returns.js","/app/startup/routes.js","/app/index.js"]},“level”:“error”,“message”:“uncaughtException: Cannot find module ‘Joi’\nRequire stack:\n- /app/routes/returns.js\n- /app/startup/routes.js\n- /app/index.js\nError: Cannot find module ‘Joi’\nRequire stack:\n- /app/routes/returns.js\n- /app/startup/routes.js\n- /app/index.js\n
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15 undefined)\n
at Function.Module._load (internal/modules/cjs/loader.js:841:27 undefined)\n
at Module.require (internal/modules/cjs/loader.js:1025:19 undefined)\n
at require .require (internal/modules/cjs/helpers.js:72:18 undefined)\n
at Object. (/app/routes/returns.js:6:13 undefined)\n
at Module._compile (internal/modules/cjs/loader.js:1137:30 undefined)\n
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10 undefined)\n
at Module.load (internal/modules/cjs/loader.js:985:32 undefined)\n
at Function.Module._load (internal/modules/cjs/loader.js:878:14 undefined)\n
at Module.require (internal/modules/cjs/loader.js:1025:19 undefined)\n
at require .require (internal/modules/cjs/helpers.js:72:18 undefined)\n
at Object. (/app/startup/routes.js:8:17 undefined)\n
at Module._compile (internal/modules/cjs/loader.js:1137:30 undefined)\n
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10 undefined)\n
at Module.load (internal/modules/cjs/loader.js:985:32 undefined)\n
at Function.Module._load (internal/modules/cjs/loader.js:878:14 undefined)”,“stack”:“Error: Cannot find module ‘Joi’\nRequire stack:\n- /app/routes/returns.js\n- /app/startup/routes.js\n- /app/index.js\n
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15 undefined)\n
at Function.Module._load (internal/modules/cjs/loader.js:841:27 undefined)\n
at Module.require (internal/modules/cjs/loader.js:1025:19 undefined)\n
at require .require (internal/modules/cjs/helpers.js:72:18 undefined)\n
at Object. (/app/routes/returns.js:6:13 undefined)\n
at Module._compile (internal/modules/cjs/loader.js:1137:30 undefined)\n
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10 undefined)\n
at Module.load (internal/modules/cjs/loader.js:985:32 undefined)\n
at Function.Module._load (internal/modules/cjs/loader.js:878:14 undefined)\n
at Module.require (internal/modules/cjs/loader.js:1025:19 undefined)\n
at require .require (internal/modules/cjs/helpers.js:72:18 undefined)\n
at Object. (/app/startup/routes.js:8:17 undefined)\n
at Module._compile (internal/modules/cjs/loader.js:1137:30 undefined)\n
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1157:10 undefined)\n
at Module.load (internal/modules/cjs/loader.js:985:32 undefined)\n
at Function.Module._load (internal/modules/cjs/loader.js:878:14)”,“exception”:true,“date”:“Sat Nov 28 2020 20:34:26 GMT+0000 (Coordinated Universal Time)”,“process”:{“pid”:23,“uid”:53884,“gid”:53884,“cwd”:"/app",“execPath”:"/app/.heroku/node/bin/node",“version”:“v12.18.4”,“argv”:["/app/.heroku/node/bin/node","/app/index.js"],“memoryUsage”:{“rss”:58798080,“heapTotal”:23080960,“heapUsed”:19316368,“external”:19721778,“arrayBuffers”:18295998}},“os”:{“loadavg”:[13.13134765625,14.974609375,17.099609375],“uptime”:106194},“trace”:[{“column”:15,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._resolveFilename”,“line”:965,“method”:"_resolveFilename",“native”:false},{“column”:27,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._load”,“line”:841,“method”:"_load",“native”:false},{“column”:19,“file”:“internal/modules/cjs/loader.js”,“function”:“Module.require”,“line”:1025,“method”:“require”,“native”:false},{“column”:18,“file”:“internal/modules/cjs/helpers.js”,“function”:“require”,“line”:72,“method”:null,“native”:false},{“column”:13,“file”:"/app/routes/returns.js",“function”:null,“line”:6,“method”:null,“native”:false},{“column”:30,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._compile”,“line”:1137,“method”:"_compile",“native”:false},{“column”:10,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._extensions…js”,“line”:1157,“method”:".js",“native”:false},{“column”:32,“file”:“internal/modules/cjs/loader.js”,“function”:“Module.load”,“line”:985,“method”:“load”,“native”:false},{“column”:14,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._load”,“line”:878,“method”:"_load",“native”:false},{“column”:19,“file”:“internal/modules/cjs/loader.js”,“function”:“Module.require”,“line”:1025,“method”:“require”,“native”:false},{“column”:18,“file”:“internal/modules/cjs/helpers.js”,“function”:“require”,“line”:72,“method”:null,“native”:false},{“column”:17,“file”:"/app/startup/routes.js",“function”:null,“line”:8,“method”:null,“native”:false},{“column”:30,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._compile”,“line”:1137,“method”:"_compile",“native”:false},{“column”:10,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._extensions…js”,“line”:1157,“method”:".js",“native”:false},{“column”:32,“file”:“internal/modules/cjs/loader.js”,“function”:“Module.load”,“line”:985,“method”:“load”,“native”:false},{“column”:14,“file”:“internal/modules/cjs/loader.js”,“function”:“Module._load”,“line”:878,“method”:"_load",“native”:false}]}
2020-11-28T20:34:27.036922+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-11-28T20:34:27.196080+00:00 app[web.1]: winston-mongodb: error initialising logger MongoNetworkError: failed to connect to server [mongodburlhere] on first connect [Error: write EPIPE
2020-11-28T20:34:27.196084+00:00 app[web.1]:
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:92:16 undefined)
2020-11-28T20:34:27.196085+00:00 app[web.1]:
at handleWriteReq .handleWriteReq (internal/stream_base_commons.js:51:26 undefined)
2020-11-28T20:34:27.196089+00:00 app[web.1]:
at writeGeneric .writeGeneric (internal/stream_base_commons.js:143:15 undefined)
2020-11-28T20:34:27.196089+00:00 app[web.1]:
at TLSSocket.Socket._writeGeneric (net.js:786:11 undefined)
2020-11-28T20:34:27.196090+00:00 app[web.1]:
at TLSSocket.Socket._write (net.js:798:8 undefined)
2020-11-28T20:34:27.196090+00:00 app[web.1]:
at doWrite .doWrite (_stream_writable.js:403:12 undefined)
2020-11-28T20:34:27.196091+00:00 app[web.1]:
at clearBuffer .clearBuffer (_stream_writable.js:542:7 undefined)
2020-11-28T20:34:27.196091+00:00 app[web.1]:
at onwrite .onwrite (_stream_writable.js:454:7 undefined)
2020-11-28T20:34:27.196092+00:00 app[web.1]:
at WriteWrap.onWriteComplete [as oncomplete] (internal/stream_base_commons.js:101:10 undefined) {
2020-11-28T20:34:27.196092+00:00 app[web.1]: name: ‘MongoNetworkError’
2020-11-28T20:34:27.196093+00:00 app[web.1]: }]
2020-11-28T20:34:27.196094+00:00 app[web.1]:
at Pool. (/app/node_modules/mongodb/lib/core/topologies/server.js:438:11 undefined)
2020-11-28T20:34:27.196094+00:00 app[web.1]:
at Pool.emit (events.js:315:20 undefined)
2020-11-28T20:34:27.196095+00:00 app[web.1]:
at /app/node_modules/mongodb/lib/core/connection/pool.js:562:14
2020-11-28T20:34:27.196095+00:00 app[web.1]:
at /app/node_modules/mongodb/lib/core/connection/pool.js:1009:9
2020-11-28T20:34:27.196096+00:00 app[web.1]:
at callback .callback (/app/node_modules/mongodb/lib/core/connection/connect.js:75:5 undefined)
2020-11-28T20:34:27.196096+00:00 app[web.1]:
at /app/node_modules/mongodb/lib/core/connection/connect.js:101:9
2020-11-28T20:34:27.196098+00:00 app[web.1]:
at _callback ._callback (/app/node_modules/mongodb/lib/core/connection/connection.js:329:7 undefined)
2020-11-28T20:34:27.196099+00:00 app[web.1]:
at Connection.errorHandler (/app/node_modules/mongodb/lib/core/connection/connection.js:344:7 undefined)
2020-11-28T20:34:27.196099+00:00 app[web.1]:
at Object.onceWrapper (events.js:422:26 undefined)
2020-11-28T20:34:27.196100+00:00 app[web.1]:
at Connection.emit (events.js:315:20 undefined)
2020-11-28T20:34:27.196100+00:00 app[web.1]:
at TLSSocket. (/app/node_modules/mongodb/lib/core/connection/connection.js:406:10 undefined)
2020-11-28T20:34:27.196101+00:00 app[web.1]:
at Object.onceWrapper (events.js:422:26 undefined)
2020-11-28T20:34:27.196101+00:00 app[web.1]:
at TLSSocket.emit (events.js:315:20 undefined)
2020-11-28T20:34:27.196102+00:00 app[web.1]:
at emitErrorNT .emitErrorNT (internal/streams/destroy.js:92:8 undefined)
2020-11-28T20:34:27.196102+00:00 app[web.1]:
at emitErrorAndCloseNT .emitErrorAndCloseNT (internal/streams/destroy.js:60:3 undefined)
2020-11-28T20:34:27.196103+00:00 app[web.1]:
at processTicksAndRejections .processTicksAndRejections (internal/process/task_queues.js:84:21 undefined)
2020-11-28T20:34:30.030051+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-28T20:34:30.030472+00:00 app[web.1]: npm ERR! errno 1
2020-11-28T20:34:30.035468+00:00 app[web.1]: npm ERR! project-vidly@1.0.0 start: node index.js
2020-11-28T20:34:30.035691+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-28T20:34:30.035969+00:00 app[web.1]: npm ERR!
2020-11-28T20:34:30.036151+00:00 app[web.1]: npm ERR! Failed at the project-vidly@1.0.0 start script.
2020-11-28T20:34:30.036349+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-28T20:34:30.053382+00:00 app[web.1]:
2020-11-28T20:34:30.053663+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-28T20:34:30.053839+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-28T20_34_30_038Z-debug.log
2020-11-28T20:34:30.110808+00:00 heroku[web.1]: Process exited with status 1
2020-11-28T20:34:30.154570+00:00 heroku[web.1]: State changed from starting to crashed"

Hey I just went through this exact same issue. All I had to do was convert all references to “Joi” to lowercase “joi” and that satisfied Heroku.