I think this is an issue with which version of NodeJS I'm using, but I'm having trouble finding the actual issue and resolution. Here is the heroku log:
2012-08-11T19:25:48+00:00 heroku[web.1]: Starting process with command
`node app.js` 2012-08-11T19:25:49+00:00 app[web.1]:
2012-08-11T19:25:49+00:00 app[web.1]: node.js:134
2012-08-11T19:25:49+00:00 app[web.1]: throw e; //
process.nextTick error, or 'error' event on first tick
2012-08-11T19:25:49+00:00 app[web.1]: Error: Cannot find module 'zlib'
2012-08-11T19:25:49+00:00 app[web.1]: ^
2012-08-11T19:25:49+00:00 app[web.1]: at Function._load
(module.js:266:25) 2012-08-11T19:25:49+00:00 app[web.1]: at
Function._resolveFilename (module.js:320:11) 2012-08-11T19:25:49+00:00
app[web.1]: at require (module.js:348:19)
2012-08-11T19:25:49+00:00 app[web.1]: at Object.<anonymous>
(/app/node_modules/express/node_modules/connect/lib/middleware/compress.js:14:12)
2012-08-11T19:25:49+00:00 app[web.1]: at Module._compile
(module.js:404:26) 2012-08-11T19:25:49+00:00 app[web.1]: at
Module.load (module.js:336:31) 2012-08-11T19:25:49+00:00 app[web.1]:
at Object..js (module.js:410:10) 2012-08-11T19:25:49+00:00 app[web.1]:
at require (module.js:348:19) 2012-08-11T19:25:49+00:00 app[web.1]:
at Object.compress
(/app/node_modules/express/node_modules/connect/lib/connect.js:89:14)
2012-08-11T19:25:49+00:00 app[web.1]: at Function._load
(module.js:297:12) 2012-08-11T19:25:50+00:00 heroku[web.1]: Process
exited with status 1 2012-08-11T19:25:50+00:00 heroku[web.1]: State
changed from starting to crashed 2012-08-11T19:25:50+00:00
heroku[web.1]: State changed from crashed to starting
2012-08-11T19:25:52+00:00 heroku[web.1]: Starting process with command
`node app.js` 2012-08-11T19:25:53+00:00 app[web.1]:
2012-08-11T19:25:53+00:00 app[web.1]: node.js:134
2012-08-11T19:25:53+00:00 app[web.1]: throw e; //
process.nextTick error, or 'error' event on first tick
2012-08-11T19:25:53+00:00 app[web.1]: ^
2012-08-11T19:25:53+00:00 app[web.1]: Error: Cannot find module 'zlib'
2012-08-11T19:25:53+00:00 app[web.1]: at Function._resolveFilename
(module.js:320:11) 2012-08-11T19:25:53+00:00 app[web.1]: at
Function._load (module.js:266:25) 2012-08-11T19:25:53+00:00
app[web.1]: at require (module.js:348:19)
2012-08-11T19:25:53+00:00 app[web.1]: at Object.<anonymous>
(/app/node_modules/express/node_modules/connect/lib/middleware/compress.js:14:12)
2012-08-11T19:25:53+00:00 app[web.1]: at Module._compile
(module.js:404:26) 2012-08-11T19:25:53+00:00 app[web.1]: at
Object..js (module.js:410:10) 2012-08-11T19:25:53+00:00 app[web.1]:
at Module.load (module.js:336:31) 2012-08-11T19:25:53+00:00
app[web.1]: at Function._load (module.js:297:12)
2012-08-11T19:25:53+00:00 app[web.1]: at require
(module.js:348:19) 2012-08-11T19:25:53+00:00 app[web.1]: at
Object.compress
(/app/node_modules/express/node_modules/connect/lib/connect.js:89:14)
And here is my package.json:
{
"name": "App" , "version": "0.0.1" , "private": true , "dependencies": {
"express": "2.5.8"
, "jade": ">= 0.0.1" }
}
I have node v0.6.13 on my local machine and am using that. Should I declare a node version in my package.json? Which version alleviates this zlib issue?
I don't know what the default version of node is on Heroku, but I think it's broken. I forced Heroku to use the version of Node.js I'm using and it worked:
{
"name": "FriendButler"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "2.5.8"
, "jade": ">= 0.0.1"
}
, "engines": {
"node": "0.6.13",
"npm": "1.1.41"
}
}
Related
I am trying to deploy a node.js app to heroku. But I am facing this ("Error: Cannot find module '../models/people' ) error. The app is working fine in localhost.
2022-11-01T17:45:47.000000+00:00 app[api]: Build succeeded
2022-11-01T17:45:47.265323+00:00 heroku[web.1]: State changed from crashed to starting
2022-11-01T17:45:50.307944+00:00 heroku[web.1]: Starting process with command `NODE_ENV=production node index.js`
2022-11-01T17:45:52.192313+00:00 app[web.1]: node:internal/modules/cjs/loader:936
2022-11-01T17:45:52.192350+00:00 app[web.1]: throw err;
2022-11-01T17:45:52.192350+00:00 app[web.1]: ^
2022-11-01T17:45:52.192351+00:00 app[web.1]:
2022-11-01T17:45:52.192351+00:00 app[web.1]: Error: Cannot find module '../models/people'
2022-11-01T17:45:52.192351+00:00 app[web.1]: Require stack:
2022-11-01T17:45:52.192351+00:00 app[web.1]: - /app/controller/login_controller.js
2022-11-01T17:45:52.192352+00:00 app[web.1]: - /app/router/login_router.js
2022-11-01T17:45:52.192352+00:00 app[web.1]: - /app/index.js
2022-11-01T17:45:52.192352+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
2022-11-01T17:45:52.192353+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27)
2022-11-01T17:45:52.192353+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-11-01T17:45:52.192353+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-11-01T17:45:52.192354+00:00 app[web.1]: at Object.<anonymous> (/app/controller/login_controller.js:2:14)
2022-11-01T17:45:52.192354+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1103:14)
2022-11-01T17:45:52.192354+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
2022-11-01T17:45:52.192355+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-11-01T17:45:52.192355+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-11-01T17:45:52.192355+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19) {
2022-11-01T17:45:52.192355+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-11-01T17:45:52.192356+00:00 app[web.1]: requireStack: [
2022-11-01T17:45:52.192356+00:00 app[web.1]: '/app/controller/login_controller.js',
2022-11-01T17:45:52.192356+00:00 app[web.1]: '/app/router/login_router.js',
2022-11-01T17:45:52.192357+00:00 app[web.1]: '/app/index.js'
2022-11-01T17:45:52.192357+00:00 app[web.1]: ]
2022-11-01T17:45:52.192357+00:00 app[web.1]: }
2022-11-01T17:45:52.307078+00:00 heroku[web.1]: Process exited with status 1
2022-11-01T17:45:52.382922+00:00 heroku[web.1]: State changed from starting to crashed
When we try to deploy our nodejs app in heroku that show us this problem !
by the way I have large app that content a lot of routes. I are not knew if can deploy it with this way I have litter confuse.
//package.json
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon ./bin/ww"
},
for runing Heroku : npm start
2021-10-17T19:17:50.244905+00:00 app[web.1]: Error: Cannot find module 'mongoose'
2021-10-17T19:17:50.244906+00:00 app[web.1]: Require stack:
2021-10-17T19:17:50.244906+00:00 app[web.1]: - /app/routes/users.js
2021-10-17T19:17:50.244906+00:00 app[web.1]: - /app/routes/index.js
2021-10-17T19:17:50.244907+00:00 app[web.1]: - /app/app.js
2021-10-17T19:17:50.244907+00:00 app[web.1]: - /app/bin/www
2021-10-17T19:17:50.244907+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
2021-10-17T19:17:50.244908+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:746:27)
2021-10-17T19:17:50.244908+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2021-10-17T19:17:50.244909+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:93:18)
2021-10-17T19:17:50.244909+00:00 app[web.1]: at Object.<anonymous> (/app/routes/users.js:10:16)
2021-10-17T19:17:50.244909+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-10-17T19:17:50.244910+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-10-17T19:17:50.244910+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2021-10-17T19:17:50.244910+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-10-17T19:17:50.244911+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:974:19) {
2021-10-17T19:17:50.244911+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-10-17T19:17:50.244911+00:00 app[web.1]: requireStack: [
2021-10-17T19:17:50.244911+00:00 app[web.1]: '/app/routes/users.js',
2021-10-17T19:17:50.244912+00:00 app[web.1]: '/app/routes/index.js',
2021-10-17T19:17:50.244912+00:00 app[web.1]: '/app/app.js',
2021-10-17T19:17:50.244912+00:00 app[web.1]: '/app/bin/www'
2021-10-17T19:17:50.244913+00:00 app[web.1]: ]
2021-10-17T19:17:50.244913+00:00 app[web.1]: }
2021-10-17T19:17:50.261989+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-17T19:17:50.262348+00:00 app[web.1]: npm ERR! errno 1
2021-10-17T19:17:50.269748+00:00 app[web.1]: npm ERR! project-work#0.0.0 start: `node ./bin/www`
2021-10-17T19:17:50.269860+00:00 app[web.1]: npm ERR! Exit status 1
2021-10-17T19:17:50.269999+00:00 app[web.1]: npm ERR!
2021-10-17T19:17:50.270110+00:00 app[web.1]: npm ERR! Failed at the project-work#0.0.0 start script.
2021-10-17T19:17:50.270230+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-17T19:17:50.274000+00:00 app[web.1]:
2021-10-17T19:17:50.274070+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-17T19:17:50.274112+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-10-17T19_17_50_270Z-debug.log
2021-10-17T19:17:50.422905+00:00 heroku[web.1]: Process exited with status 1
2021-10-17T19:17:50.494116+00:00 heroku[web.1]: State changed from starting to crashed
2021-10-17T19:17:50.498518+00:00 heroku[web.1]: State changed from crashed to starting
2021-10-17T19:17:52.375838+00:00 heroku[web.1]: Starting process with command `
I am deploying a fullstack react/express app to Heroku, it has managed to deploy. There are multiple errors in the Heroku logs which I have cannot seem to understand/figure out. I also have a Procfile with web: node server.js
I have tried to clear cache - delete node_modules and package.json then npm install again but this has not made a difference.
Heroku Logs
2020-11-15T13:08:12.713935+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:08:12.713935+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:08:12.713935+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:08:12.783289+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:08:12.818062+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:08:12.826070+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:08:21.448256+00:00 heroku[web.1]: Starting process with command `node server.js`
2020-11-15T13:08:24.324135+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:08:24.324170+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:08:24.324175+00:00 app[web.1]: ^
2020-11-15T13:08:24.324175+00:00 app[web.1]:
2020-11-15T13:08:24.324180+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2020-11-15T13:08:24.324185+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:08:24.324185+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:08:24.324190+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:08:24.324190+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:08:24.324190+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:08:24.324192+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:08:24.324196+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:08:24.418110+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:08:24.454083+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:23:24.786742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=obscure-journey-43421.herokuapp.com request_id=aa6c54d3-cfe3-4f74-b4c5-93018f00ba97 fwd="84.9.66.95" dyno= connect= service= status=503 bytes= protocol=https
2020-11-15T13:23:26.240301+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-journey-43421.herokuapp.com request_id=ec07ad1c-091f-4e53-b50d-9632b66dd2d4 fwd="84.9.66.95" dyno= connect= service= status=503 bytes= protocol=https
2020-11-15T13:27:28.000000+00:00 app[api]: Build started by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.458958+00:00 app[api]: Deploy 12d81f3b by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.458958+00:00 app[api]: Release v12 created by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.625747+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:29:09.000000+00:00 app[api]: Build succeeded
2020-11-15T13:29:17.927953+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-15T13:29:20.083139+00:00 app[web.1]:
2020-11-15T13:29:20.083155+00:00 app[web.1]: > movie-database#1.0.0 start /app
2020-11-15T13:29:20.083155+00:00 app[web.1]: > node server.js
2020-11-15T13:29:20.083155+00:00 app[web.1]:
2020-11-15T13:29:20.795200+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:29:20.795248+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:29:20.795250+00:00 app[web.1]: ^
2020-11-15T13:29:20.795250+00:00 app[web.1]:
2020-11-15T13:29:20.795251+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2020-11-15T13:29:20.795252+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:29:20.795254+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:29:20.795254+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:29:20.795257+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:29:20.795258+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:29:20.810114+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-15T13:29:20.810451+00:00 app[web.1]: npm ERR! errno 1
2020-11-15T13:29:20.817598+00:00 app[web.1]: npm ERR! movie-database#1.0.0 start: `node server.js`
2020-11-15T13:29:20.817850+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-15T13:29:20.818099+00:00 app[web.1]: npm ERR!
2020-11-15T13:29:20.818312+00:00 app[web.1]: npm ERR! Failed at the movie-database#1.0.0 start script.
2020-11-15T13:29:20.818490+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-15T13:29:20.827750+00:00 app[web.1]:
2020-11-15T13:29:20.828041+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-15T13:29:20.828210+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-15T13_29_20_819Z-debug.log
2020-11-15T13:29:20.877545+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:29:20.913439+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:29:20.917070+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:29:33.460653+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-15T13:29:36.844587+00:00 app[web.1]:
2020-11-15T13:29:36.844630+00:00 app[web.1]: > movie-database#1.0.0 start /app
2020-11-15T13:29:36.844631+00:00 app[web.1]: > node server.js
2020-11-15T13:29:36.844631+00:00 app[web.1]:
2020-11-15T13:29:38.011159+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:29:38.011219+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:29:38.011220+00:00 app[web.1]: ^
2020-11-15T13:29:38.011220+00:00 app[web.1]:
2020-11-15T13:29:38.011224+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2020-11-15T13:29:38.011224+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:29:38.011225+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:29:38.011226+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:29:38.011226+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:29:38.011226+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:29:38.011228+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:29:38.011228+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:29:38.011229+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:29:38.046555+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-15T13:29:38.047758+00:00 app[web.1]: npm ERR! errno 1
2020-11-15T13:29:38.059446+00:00 app[web.1]: npm ERR! movie-database#1.0.0 start: node server.js
2020-11-15T13:29:38.059681+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-15T13:29:38.059955+00:00 app[web.1]: npm ERR!
2020-11-15T13:29:38.060192+00:00 app[web.1]: npm ERR! Failed at the movie-database#1.0.0 start script.
2020-11-15T13:29:38.060432+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-15T13:29:38.096793+00:00 app[web.1]:
2020-11-15T13:29:38.097273+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-15T13:29:38.097587+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-15T13_29_38_061Z-debug.log
2020-11-15T13:29:38.193702+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:29:38.242866+00:00 heroku[web.1]: State changed from starting to crashed
Server.js
const express = require('express');
const app = express();
const path = require('path');
const cors = require('cors');
const port = process.env.PORT || 5000;
const dotenv = require('dotenv');
const mongoose = require('mongoose');
// Auth Routes
const authRoute = require('./routes/auth');
dotenv.config();
//Connect to DB
mongoose.connect(process.env.DB_CONNECT,
{ useNewUrlParser: true, useUnifiedTopology: true },
() => console.log('connected to DB!')
);
// Serve static files from the React app
app.use(express.static(path.join(__dirname, 'client/build/')));
// Middleware
app.use(express.json());
app.use(cors());
// Put all API endpoints under '/api'
app.use('/api', authRoute)
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client/build/index.html'));
});
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});
Package.json
{
"name": "movie-database",
"version": "1.0.0",
"description": "Small application created with React.js, react router and the movie database to showcase all latest, upcoming and most popular movies.",
"main": "server.js",
"scripts": {
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm run build"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"joi": "^17.3.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
"mongoose": "^5.10.12",
"nodemon": "^2.0.6",
"password-generator": "^2.3.2",
"serve": "^11.3.2"
}
}
I cannot figure out what is going wrong?
I am trying to deploy my twitch chatbot to heroku.
I can run it normally using node main.js in cmd.
2020-07-13T12:18:52.325944+00:00 heroku[web.1]: Starting process with command `node main.js`
2020-07-13T12:18:55.572924+00:00 heroku[web.1]: Process exited with status 1
2020-07-13T12:18:55.695565+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-13T12:18:55.490284+00:00 app[web.1]: internal/modules/cjs/loader.js:969
2020-07-13T12:18:55.490415+00:00 app[web.1]: throw err;
2020-07-13T12:18:55.490416+00:00 app[web.1]: ^
2020-07-13T12:18:55.490417+00:00 app[web.1]:
2020-07-13T12:18:55.490423+00:00 app[web.1]: Error: Cannot find module 'tmi.js'
2020-07-13T12:18:55.490424+00:00 app[web.1]: Require stack:
2020-07-13T12:18:55.490424+00:00 app[web.1]: - /app/main.js
2020-07-13T12:18:55.490430+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
2020-07-13T12:18:55.490430+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:842:27)
2020-07-13T12:18:55.490434+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1026:19)
2020-07-13T12:18:55.490435+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-07-13T12:18:55.490435+00:00 app[web.1]: at Object.<anonymous> (/app/main.js:1:13)
2020-07-13T12:18:55.490435+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1138:30)
2020-07-13T12:18:55.490436+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
2020-07-13T12:18:55.490436+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:986:32)
2020-07-13T12:18:55.490436+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:879:14)
2020-07-13T12:18:55.490440+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
2020-07-13T12:18:55.490450+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-07-13T12:18:55.490451+00:00 app[web.1]: requireStack: [ '/app/main.js' ]
2020-07-13T12:18:55.490451+00:00 app[web.1]: }
i checked in heroku bash, all are in the same directory
ProcFile main.js node_modules package.json package-lock.json
i tried replacing const tmi = require('tmi.js');
with
const tmi = require('./tmi.js');
const tmi = require('./node_modules/tmi.js');
const tmi = require('node/modules/tmi.js');
i also tried putting /node_modules in a gitignore file
i have a ProcFile with
web: node main.js
which Heroku Dyno is set to.
here is my package.json
{
"name": "bot",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Gian",
"license": "ISC"
}
Thank you for any/all your answers.
My Node + Express server is working locally but not on Heroku.
Also worth mentioning I'm using heroku-postgres and ran these commands
heroku run knex migrate:latest -a myAppName
heroku run knex seed:latest -a myAppName
The commands ran successfully and I can see the seeded DB on Heroku.
What's the issue?
Now when I try to access the server, it just won't work because of some modules it can't find, but again it works perfectly on my end
I'm also deploying from my development-branch, haven't yet merged to master but that shouldn't be the problem.
Heroku Logs:
2019-11-20T19:57:57.678058+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-20T19:57:57.524659+00:00 app[web.1]: internal/modules/cjs/loader.js:895
2019-11-20T19:57:57.524683+00:00 app[web.1]: throw err;
2019-11-20T19:57:57.524685+00:00 app[web.1]: ^
2019-11-20T19:57:57.524686+00:00 app[web.1]:
2019-11-20T19:57:57.524689+00:00 app[web.1]: Error: Cannot find module '../../Users/Middlewares/validateUserID'
2019-11-20T19:57:57.524690+00:00 app[web.1]: Require stack:
2019-11-20T19:57:57.524692+00:00 app[web.1]: - /app/Issues/Routes/IssueRoutes.js
2019-11-20T19:57:57.524694+00:00 app[web.1]: - /app/api/server.js
2019-11-20T19:57:57.524695+00:00 app[web.1]: - /app/index.js
2019-11-20T19:57:57.524697+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
2019-11-20T19:57:57.524698+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:785:27)
2019-11-20T19:57:57.524700+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:57:57.524702+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:57:57.524703+00:00 app[web.1]: at Object.<anonymous> (/app/Issues/Routes/IssueRoutes.js:6:28)
2019-11-20T19:57:57.524704+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:57:57.524706+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:57:57.524707+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:57:57.524708+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14)
2019-11-20T19:57:57.524710+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:57:57.524711+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:57:57.524712+00:00 app[web.1]: at Object.<anonymous> (/app/api/server.js:10:21)
2019-11-20T19:57:57.524713+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:57:57.524715+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:57:57.524716+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:57:57.524717+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14) {
2019-11-20T19:57:57.524718+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-11-20T19:57:57.524720+00:00 app[web.1]: requireStack: [
2019-11-20T19:57:57.524721+00:00 app[web.1]: '/app/Issues/Routes/IssueRoutes.js',
2019-11-20T19:57:57.524722+00:00 app[web.1]: '/app/api/server.js',
2019-11-20T19:57:57.524724+00:00 app[web.1]: '/app/index.js'
2019-11-20T19:57:57.524725+00:00 app[web.1]: ]
2019-11-20T19:57:57.524726+00:00 app[web.1]: }
2019-11-20T19:57:57.533660+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-11-20T19:57:57.534079+00:00 app[web.1]: npm ERR! errno 1
2019-11-20T19:57:57.536043+00:00 app[web.1]: npm ERR! bettercity#1.0.0 start: `node index.js`
2019-11-20T19:57:57.536045+00:00 app[web.1]: npm ERR! Exit status 1
2019-11-20T19:57:57.536154+00:00 app[web.1]: npm ERR!
2019-11-20T19:57:57.536817+00:00 app[web.1]: npm ERR! Failed at the bettercity#1.0.0 start script.
2019-11-20T19:57:57.536821+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-11-20T19:57:57.563676+00:00 app[web.1]:
2019-11-20T19:57:57.564106+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-11-20T19:57:57.564508+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-11-20T19_57_57_537Z-debug.log
2019-11-20T19:57:57.659267+00:00 heroku[web.1]: Process exited with status 1
2019-11-20T19:58:25.000000+00:00 app[api]: Build started by user myEmail#mail.com
2019-11-20T19:59:21.041005+00:00 app[api]: Deploy a1b6ff8e by user myEmail#mail.com
2019-11-20T19:59:21.041005+00:00 app[api]: Release v20 created by user myEmail#mail.com
2019-11-20T19:59:21.000000+00:00 app[api]: Build succeeded
2019-11-20T19:59:22.528003+00:00 heroku[web.1]: State changed from crashed to starting
2019-11-20T19:59:26.144682+00:00 heroku[web.1]: Starting process with command `npm start`
2019-11-20T19:59:29.286295+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-20T19:59:28.777609+00:00 app[web.1]:
2019-11-20T19:59:28.777626+00:00 app[web.1]: > bettercity#1.0.0 start /app
2019-11-20T19:59:28.777628+00:00 app[web.1]: > node index.js
2019-11-20T19:59:28.777629+00:00 app[web.1]:
2019-11-20T19:59:29.268829+00:00 heroku[web.1]: Process exited with status 1
2019-11-20T19:59:29.169740+00:00 app[web.1]: internal/modules/cjs/loader.js:895
2019-11-20T19:59:29.169765+00:00 app[web.1]: throw err;
2019-11-20T19:59:29.169766+00:00 app[web.1]: ^
2019-11-20T19:59:29.169767+00:00 app[web.1]:
2019-11-20T19:59:29.169779+00:00 app[web.1]: Error: Cannot find module '../../Users/Middlewares/validateUserID'
2019-11-20T19:59:29.169780+00:00 app[web.1]: Require stack:
2019-11-20T19:59:29.169781+00:00 app[web.1]: - /app/Issues/Routes/IssueRoutes.js
2019-11-20T19:59:29.169782+00:00 app[web.1]: - /app/api/server.js
2019-11-20T19:59:29.169783+00:00 app[web.1]: - /app/index.js
2019-11-20T19:59:29.169784+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
2019-11-20T19:59:29.169785+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:785:27)
2019-11-20T19:59:29.169786+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:59:29.169787+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:59:29.169788+00:00 app[web.1]: at Object.<anonymous> (/app/Issues/Routes/IssueRoutes.js:6:28)
2019-11-20T19:59:29.169789+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:59:29.169790+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:59:29.169791+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:59:29.169792+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14)
2019-11-20T19:59:29.169793+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:956:19)
2019-11-20T19:59:29.169794+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-11-20T19:59:29.169795+00:00 app[web.1]: at Object.<anonymous> (/app/api/server.js:10:21)
2019-11-20T19:59:29.169796+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30)
2019-11-20T19:59:29.169797+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
2019-11-20T19:59:29.169798+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:914:32)
2019-11-20T19:59:29.169799+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:822:14) {
2019-11-20T19:59:29.169800+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-11-20T19:59:29.169801+00:00 app[web.1]: requireStack: [
2019-11-20T19:59:29.169802+00:00 app[web.1]: '/app/Issues/Routes/IssueRoutes.js',
2019-11-20T19:59:29.169803+00:00 app[web.1]: '/app/api/server.js',
2019-11-20T19:59:29.169804+00:00 app[web.1]: '/app/index.js'
2019-11-20T19:59:29.169805+00:00 app[web.1]: ]
2019-11-20T19:59:29.169806+00:00 app[web.1]: }
2019-11-20T19:59:29.179485+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-11-20T19:59:29.179812+00:00 app[web.1]: npm ERR! errno 1
2019-11-20T19:59:29.181606+00:00 app[web.1]: npm ERR! bettercity#1.0.0 start: `node index.js`
2019-11-20T19:59:29.181811+00:00 app[web.1]: npm ERR! Exit status 1
2019-11-20T19:59:29.182146+00:00 app[web.1]: npm ERR!
2019-11-20T19:59:29.182403+00:00 app[web.1]: npm ERR! Failed at the bettercity#1.0.0 start script.
2019-11-20T19:59:29.182699+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-11-20T19:59:29.198787+00:00 app[web.1]:
2019-11-20T19:59:29.199117+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-11-20T19:59:29.199119+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-11-20T19_59_29_183Z-debug.log
package.json
{
"name": "bettercity",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"server": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rodpa715/bettercity.git"
},
"author": "Patrick Rodrigues",
"license": "ISC",
"bugs": {
"url": "https://github.com/rodpa715/bettercity/issues"
},
"homepage": "https://github.com/rodpa715/bettercity#readme",
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^3.21.2",
"jsonwebtoken": "^8.5.1",
"knex": "^0.20.2",
"node": "^13.1.0",
"pg": "^7.12.1"
},
"engines": {
"node": "^10.16.3",
"npm": "6.13.0"
},
"devDependencies": {
"jest": "^24.9.0",
"nodemon": "^1.19.4",
"supertest": "^4.0.2"
}
}
[SOLVED]
It seems as though GitHub doesn't track folder case-sensitivity change so even when I renamed the folders it didn't work. I copied everything into a new repo and it deployed successfully.
Try changing
const { validateUserID } = require("../../Users/Middlewares/validateUserID");
to
const { validateUserID } = require("../../users/Middlewares/validateUserID");
with a lowercase users
linux is case sensitive and it might be giving issues on a server but not on your machine if you have a mac.
Your paths to the routes are incorrect and node cannot find those in the Heroku filesystem.
Work off your current file using like './' so you update to:
const authRoutes = require("./../Authentication/Routes/AuthRoutes");