Home > OS >  I'm trying to deploy my node.js discord bot on heroku but I keep getting errors
I'm trying to deploy my node.js discord bot on heroku but I keep getting errors

Time:10-12

I was trying to deploy my discord.js bot on heroku but I always get an error and the bot crashes. I codes are fine, I ran it on my pc and it does not give any errors. I followed this link to set up my heroku app https://devcenter.heroku.com/articles/getting-started-with-nodejs#set-up. I did exactly as it said but I get this error:

2021-10-12T08:15:45.604131 00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-12T08:15:46.708903 00:00 app[web.1]:
2021-10-12T08:15:46.709032 00:00 app[web.1]: > kurumi@1.0.0 start /app
2021-10-12T08:15:46.709036 00:00 app[web.1]: > node index.js
2021-10-12T08:15:46.709036 00:00 app[web.1]:
2021-10-12T08:15:46.772460 00:00 app[web.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2021-10-12T08:15:46.772464 00:00 app[web.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2021-10-12T08:15:46.772465 00:00 app[web.1]: ^^^
2021-10-12T08:15:46.772465 00:00 app[web.1]:
2021-10-12T08:15:46.772468 00:00 app[web.1]: SyntaxError: Unexpected token '??='
2021-10-12T08:15:46.772468 00:00 app[web.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2021-10-12T08:15:46.772468 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2021-10-12T08:15:46.772471 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-10-12T08:15:46.772471 00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2021-10-12T08:15:46.772471 00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-10-12T08:15:46.772471 00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2021-10-12T08:15:46.772472 00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:93:18)
2021-10-12T08:15:46.772472 00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2021-10-12T08:15:46.772472 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-10-12T08:15:46.772472 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-10-12T08:15:46.779715 00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-12T08:15:46.779895 00:00 app[web.1]: npm ERR! errno 1
2021-10-12T08:15:46.783479 00:00 app[web.1]: npm ERR! kurumi@1.0.0 start: `node index.js`
2021-10-12T08:15:46.783529 00:00 app[web.1]: npm ERR! Exit status 1
2021-10-12T08:15:46.783595 00:00 app[web.1]: npm ERR!
2021-10-12T08:15:46.783640 00:00 app[web.1]: npm ERR! Failed at the kurumi@1.0.0 start script.
2021-10-12T08:15:46.783698 00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-12T08:15:46.786955 00:00 app[web.1]:
2021-10-12T08:15:46.787031 00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-12T08:15:46.787064 00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-12T08_15_46_784Z-debug.log
2021-10-12T08:15:46.938086 00:00 heroku[web.1]: Process exited with status 1
2021-10-12T08:15:47.109411 00:00 heroku[web.1]: State changed from starting to crashed
2021-10-12T08:15:47.120433 00:00 heroku[web.1]: State changed from crashed to starting
2021-10-12T08:15:50.000000 00:00 app[api]: Build succeeded
2021-10-12T08:15:51.902833 00:00 heroku[web.1]: Starting process with command `npm start`
2021-10-12T08:15:52.879739 00:00 app[web.1]:
2021-10-12T08:15:52.879754 00:00 app[web.1]: > kurumi@1.0.0 start /app
2021-10-12T08:15:52.879755 00:00 app[web.1]: > node index.js
2021-10-12T08:15:52.879755 00:00 app[web.1]:
2021-10-12T08:15:52.943619 00:00 app[web.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2021-10-12T08:15:52.943621 00:00 app[web.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2021-10-12T08:15:52.943621 00:00 app[web.1]: ^^^
2021-10-12T08:15:52.943622 00:00 app[web.1]:
2021-10-12T08:15:52.943622 00:00 app[web.1]: SyntaxError: Unexpected token '??='
2021-10-12T08:15:52.943623 00:00 app[web.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2021-10-12T08:15:52.943623 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2021-10-12T08:15:52.943624 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-10-12T08:15:52.943624 00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2021-10-12T08:15:52.943624 00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-10-12T08:15:52.943625 00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2021-10-12T08:15:52.943625 00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:93:18)
2021-10-12T08:15:52.943625 00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2021-10-12T08:15:52.943627 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-10-12T08:15:52.943627 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-10-12T08:15:52.950345 00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-10-12T08:15:52.950523 00:00 app[web.1]: npm ERR! errno 1
2021-10-12T08:15:52.953970 00:00 app[web.1]: npm ERR! kurumi@1.0.0 start: `node index.js`
2021-10-12T08:15:52.954012 00:00 app[web.1]: npm ERR! Exit status 1
2021-10-12T08:15:52.954061 00:00 app[web.1]: npm ERR!
2021-10-12T08:15:52.954092 00:00 app[web.1]: npm ERR! Failed at the kurumi@1.0.0 start script.
2021-10-12T08:15:52.954134 00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-10-12T08:15:52.956414 00:00 app[web.1]:
2021-10-12T08:15:52.956490 00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-10-12T08:15:52.956517 00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-10-12T08_15_52_954Z-debug.log
2021-10-12T08:15:53.132196 00:00 heroku[web.1]: Process exited with status 1
2021-10-12T08:15:53.198551 00:00 heroku[web.1]: State changed from starting to crashed
2021-10-12T08:16:14.979868 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-thicket-97709.herokuapp.com request_id=bc0fd458-0a88-4f7f-8fe6-7a21d52e3035 fwd="114.31.4.178" dyno= connect= service= status=503 bytes= protocol=https
2021-10-12T08:16:15.988690 00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-thicket-97709.herokuapp.com request_id=b830f6e2-5525-4310-b415-4e902015b8e3 fwd="114.31.4.178" dyno= connect= service= status=503 bytes= protocol=https

CodePudding user response:

Heroku have very low nodejs version and you can't update it sadly, so there is no real way to fix it. You still can run a bot here if it works on djs v12.5.3

CodePudding user response:

You can specify a node version in the package.json with the engines property when using heroku. Can you try setting the version to 15 or higher?

{
  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "15.x"
  }
}
  • Related