Discord.js Heroku error: Unexpected token ??=
Discord.js Heroku error: Unexpected token ??=
我目前正在研究 Discord bot and i want to deploy a hosting named Heroku。
但是如果我想尝试部署到 Heroku,它 return 是一个错误。这是错误:
2021-12-14T16:25:08.161176+00:00 app[web.1]: > mystery-federation-bot@1.0.0 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)
感谢您回答我的问题!
在package.json
中,请将此放入package.json
:
"engines": {
"node": "16.x",
"npm": "7.x"
},
已满:
{
"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.
我目前正在研究 Discord bot and i want to deploy a hosting named Heroku。
但是如果我想尝试部署到 Heroku,它 return 是一个错误。这是错误:
2021-12-14T16:25:08.161176+00:00 app[web.1]: > mystery-federation-bot@1.0.0 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)
感谢您回答我的问题!
在package.json
中,请将此放入package.json
:
"engines": {
"node": "16.x",
"npm": "7.x"
},
已满:
{
"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.