I want to host my discord bot on Heroku but when i do git push heroku it says it's TypeError
But when i run my bot on my pc it works perfect.. so i don't understand what's problem with heroku..
Error:
2020-01-05T11:50:17.718173+00:00 heroku[web.1]: State changed from starting to crashed
2020-01-05T11:50:17.636956+00:00 app[web.1]: TypeError: Cannot set property 'port' of undefined
2020-01-05T11:50:17.636975+00:00 app[web.1]: at Object.<anonymous> (/app/src/config.js:149:19)
2020-01-05T11:50:17.636977+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2020-01-05T11:50:17.636980+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2020-01-05T11:50:17.636982+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2020-01-05T11:50:17.636984+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2020-01-05T11:50:17.636986+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2020-01-05T11:50:17.636988+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-01-05T11:50:17.636990+00:00 app[web.1]: at Object.<anonymous> (/app/src/index.js:44:16)
2020-01-05T11:50:17.636993+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2020-01-05T11:50:17.636994+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2020-01-05T11:50:17.705478+00:00 heroku[web.1]: Process exited with status 1```
I think the app cannot bind to the given (hardcoded?) port and it fails. Heroku runtime provides you with an environment variable PORT (upper case): you should use that to define the port of your app.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.