I'm currently working on a discord bot and I'm trying to deploy it on Heroku. I've encountered many errors already and I always fixed them, but I just can't get over this one. I've already searched like 10 stack overflow questions, but there just wasn't anything that fixed my problem. I've tried looking into the error, but I don't understand what I could do to fix it. It should be that "??=" isn't supported on versions of Node lower than 16.60.0. But I didn't find any way to update node on Heroku. Could you please help me? Thanks! The error:
2021-12-14T16:17:03.520682 00:00 heroku[run.7027]: Process exited with status 127
2021-12-14T16:17:03.573697 00:00 heroku[run.7027]: State changed from up to complete
2021-12-14T16:18:28.962057 00:00 app[api]: Starting process with command `node update` by user [email protected]
2021-12-14T16:18:31.192401 00:00 heroku[run.5328]: Awaiting client
2021-12-14T16:18:31.218566 00:00 heroku[run.5328]: Starting process with command `node update`
2021-12-14T16:18:31.228082 00:00 heroku[run.5328]: State changed from starting to up
2021-12-14T16:18:34.583362 00:00 heroku[run.5328]: Process exited with status 1
2021-12-14T16:18:34.638276 00:00 heroku[run.5328]: State changed from up to complete
2021-12-14T16:24:38.000000 00:00 app[api]: Build started by user [email protected]
2021-12-14T16:25:05.312966 00:00 heroku[web.1]: State changed from crashed to starting
2021-12-14T16:25:08.350152 00:00 heroku[web.1]: Process exited with status 1
2021-12-14T16:25:07.232637 00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-14T16:25:08.464246 00:00 heroku[web.1]: State changed from starting to crashed
2021-12-14T16:25:08.506248 00:00 heroku[web.1]: State changed from crashed to starting
2021-12-14T16:25:08.161164 00:00 app[web.1]:
2021-12-14T16:25:08.161176 00:00 app[web.1]: > [email protected] start /app
2021-12-14T16:25:08.161176 00:00 app[web.1]: > node index.js
2021-12-14T16:25:08.161177 00:00 app[web.1]:
2021-12-14T16:25:08.207168 00:00 app[web.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2021-12-14T16:25:08.207170 00:00 app[web.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2021-12-14T16:25:08.207170 00:00 app[web.1]: ^^^
2021-12-14T16:25:08.207171 00:00 app[web.1]:
2021-12-14T16:25:08.207171 00:00 app[web.1]: SyntaxError: Unexpected token '??='
2021-12-14T16:25:08.207171 00:00 app[web.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2021-12-14T16:25:08.207172 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2021-12-14T16:25:08.207172 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-14T16:25:08.207172 00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2021-12-14T16:25:08.207173 00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-12-14T16:25:08.207173 00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2021-12-14T16:25:08.207173 00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:93:18)
2021-12-14T16:25:08.207173 00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2021-12-14T16:25:08.207174 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-12-14T16:25:08.207174 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-14T16:25:08.215671 00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-12-14T16:25:08.215915 00:00 app[web.1]: npm ERR! errno 1
2021-12-14T16:25:08.220723 00:00 app[web.1]: npm ERR! [email protected] start: `node index.js`
2021-12-14T16:25:08.220764 00:00 app[web.1]: npm ERR! Exit status 1
2021-12-14T16:25:08.220825 00:00 app[web.1]: npm ERR!
2021-12-14T16:25:08.220844 00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2021-12-14T16:25:08.220911 00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-12-14T16:25:08.225844 00:00 app[web.1]:
2021-12-14T16:25:08.225952 00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-12-14T16:25:08.225999 00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-12-14T16_25_08_221Z-debug.log
2021-12-14T16:25:02.547929 00:00 app[api]: Deploy 8c5680e8 by user [email protected]
2021-12-14T16:25:03.000000 00:00 app[api]: Build succeeded
2021-12-14T16:25:10.468939 00:00 heroku[web.1]: Starting process with command `npm start`
2021-12-14T16:25:11.669170 00:00 app[web.1]:
2021-12-14T16:25:11.669182 00:00 app[web.1]: > [email protected] start /app
2021-12-14T16:25:11.669182 00:00 app[web.1]: > node index.js
2021-12-14T16:25:11.669183 00:00 app[web.1]:
2021-12-14T16:25:11.734005 00:00 app[web.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2021-12-14T16:25:11.734006 00:00 app[web.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2021-12-14T16:25:11.734006 00:00 app[web.1]: ^^^
2021-12-14T16:25:11.734007 00:00 app[web.1]:
2021-12-14T16:25:11.734007 00:00 app[web.1]: SyntaxError: Unexpected token '??='
2021-12-14T16:25:11.734007 00:00 app[web.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2021-12-14T16:25:11.734008 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2021-12-14T16:25:11.734008 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-14T16:25:11.734008 00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2021-12-14T16:25:11.734009 00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2021-12-14T16:25:11.734009 00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2021-12-14T16:25:11.734009 00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:93:18)
2021-12-14T16:25:11.734009 00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2021-12-14T16:25:11.734010 00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2021-12-14T16:25:11.734010 00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2021-12-14T16:25:11.740611 00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-12-14T16:25:11.740808 00:00 app[web.1]: npm ERR! errno 1
2021-12-14T16:25:11.744319 00:00 app[web.1]: npm ERR! [email protected] start: `node index.js`
2021-12-14T16:25:11.744364 00:00 app[web.1]: npm ERR! Exit status 1
2021-12-14T16:25:11.744425 00:00 app[web.1]: npm ERR!
2021-12-14T16:25:11.744478 00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2021-12-14T16:25:11.744505 00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-12-14T16:25:11.750109 00:00 app[web.1]:
2021-12-14T16:25:11.750187 00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-12-14T16:25:11.750221 00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-12-14T16_25_11_744Z-debug.log
2021-12-14T16:25:02.547929 00:00 app[api]: Release v5 created by user [email protected]
2021-12-14T16:25:11.986946 00:00 heroku[web.1]: State changed from starting to crashed
2021-12-14T16:25:11.885913 00:00 heroku[web.1]: Process exited with status 1
CodePudding user response:
In the package.json
, please place this into the package.json
:
"engines": {
"node": "16.x",
"npm": "7.x"
},
Full:
{
"name": "your bot name",
"version": "1.0.0",
"description": "your bot description",
"main": "index.js",
"engines": {
"node": "16.x",
"npm": "7.x"
},
"scripts": {
"start": "node ."
},
"author": "your name",
"license": "MIT",
"dependencies": {
"discord.js": "^13.1.0"
}
}
Credit: Thanks to @Zsolt Meszaros for the answer.