我想在Heroku上托管我的Discord机器人,但是当我执行git push heroku时,它说它是TypeError
但是当我在PC上运行我的机器人时,它可以完美运行..因此我不明白heroku的问题是什么。
错误:
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```
答案 0 :(得分:0)
我认为该应用程序无法绑定到给定的(硬编码?)端口,并且失败。 Heroku运行时为您提供了一个环境变量PORT(大写):您应该使用它来定义应用程序的端口。
祝你好运, 哔哔