Heroku Node.js Discord.js 部署失败
Heroku Node.js Discord.js deployment failed
不确定是什么问题,
不得不跟随几个 yt-bers 一个使用 tsc 但不得不完全切换到 js。
2022-01-09T20:58:40.370270+00:00 app[worker.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2022-01-09T20:58:40.370282+00:00 app[worker.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2022-01-09T20:58:40.370282+00:00 app[worker.1]: ^^^
2022-01-09T20:58:40.370283+00:00 app[worker.1]:
2022-01-09T20:58:40.370283+00:00 app[worker.1]: SyntaxError: Unexpected token '??='
2022-01-09T20:58:40.370284+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2022-01-09T20:58:40.370284+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2022-01-09T20:58:40.370284+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2022-01-09T20:58:40.370285+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2022-01-09T20:58:40.370285+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2022-01-09T20:58:40.370286+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2022-01-09T20:58:40.370286+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:93:18)
2022-01-09T20:58:40.370286+00:00 app[worker.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2022-01-09T20:58:40.370287+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2022-01-09T20:58:40.370287+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2022-01-09T20:58:40.611984+00:00 heroku[worker.1]: State changed from up to crashed
SyntaxError: Unexpected token '??='
您使用的 Node.js 版本不支持 the nullish assignment operator, ??=
. That operator 。
通过在您的 package.json
中包含 engines
部分,要求 Heroku 使用 Node 16(或更高版本),例如
{
"name": "Some Application",
"description": "An application that does cool stuff",
"version": "1.0.0",
"engines": {
"node": "16.x"
}
}
不确定是什么问题, 不得不跟随几个 yt-bers 一个使用 tsc 但不得不完全切换到 js。
2022-01-09T20:58:40.370270+00:00 app[worker.1]: /app/node_modules/discord.js/src/rest/APIRequest.js:33
2022-01-09T20:58:40.370282+00:00 app[worker.1]: agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
2022-01-09T20:58:40.370282+00:00 app[worker.1]: ^^^
2022-01-09T20:58:40.370283+00:00 app[worker.1]:
2022-01-09T20:58:40.370283+00:00 app[worker.1]: SyntaxError: Unexpected token '??='
2022-01-09T20:58:40.370284+00:00 app[worker.1]: at wrapSafe (internal/modules/cjs/loader.js:1001:16)
2022-01-09T20:58:40.370284+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1049:27)
2022-01-09T20:58:40.370284+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2022-01-09T20:58:40.370285+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:950:32)
2022-01-09T20:58:40.370285+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:790:12)
2022-01-09T20:58:40.370286+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:974:19)
2022-01-09T20:58:40.370286+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:93:18)
2022-01-09T20:58:40.370286+00:00 app[worker.1]: at Object.<anonymous> (/app/node_modules/discord.js/src/rest/RESTManager.js:4:20)
2022-01-09T20:58:40.370287+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1085:14)
2022-01-09T20:58:40.370287+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
2022-01-09T20:58:40.611984+00:00 heroku[worker.1]: State changed from up to crashed
SyntaxError: Unexpected token '??='
您使用的 Node.js 版本不支持 the nullish assignment operator, ??=
. That operator
通过在您的 package.json
中包含 engines
部分,要求 Heroku 使用 Node 16(或更高版本),例如
{
"name": "Some Application",
"description": "An application that does cool stuff",
"version": "1.0.0",
"engines": {
"node": "16.x"
}
}