Heroku 应用程序在启动 discordjs 时崩溃

Heroku Application crashing on startup discordjs

2022-03-13T12:28:53.072745+00:00 app[worker.1]: node:internal/modules/cjs/loader:1183
2022-03-13T12:28:53.072757+00:00 app[worker.1]:   return process.dlopen(module, path.toNamespacedPath(filename));
2022-03-13T12:28:53.072757+00:00 app[worker.1]:                  ^
2022-03-13T12:28:53.072758+00:00 app[worker.1]: 
2022-03-13T12:28:53.072758+00:00 app[worker.1]: Error: /app/node_modules/canvas/build/Release/canvas.node: invalid ELF header
2022-03-13T12:28:53.072758+00:00 app[worker.1]:     at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-03-13T12:28:53.072759+00:00 app[worker.1]:     at Module.load (node:internal/modules/cjs/loader:975:32)
2022-03-13T12:28:53.072759+00:00 app[worker.1]:     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-03-13T12:28:53.072759+00:00 app[worker.1]:     at Module.require (node:internal/modules/cjs/loader:999:19)
2022-03-13T12:28:53.072760+00:00 app[worker.1]:     at require (node:internal/modules/cjs/helpers:102:18)
2022-03-13T12:28:53.072760+00:00 app[worker.1]:     at Object.<anonymous> (/app/node_modules/canvas/lib/bindings.js:3:18)
2022-03-13T12:28:53.072760+00:00 app[worker.1]:     at Module._compile (node:internal/modules/cjs/loader:1099:14)
2022-03-13T12:28:53.072761+00:00 app[worker.1]:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-03-13T12:28:53.072761+00:00 app[worker.1]:     at Module.load (node:internal/modules/cjs/loader:975:32)
2022-03-13T12:28:53.072761+00:00 app[worker.1]:     at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-03-13T12:28:53.072762+00:00 app[worker.1]:   code: 'ERR_DLOPEN_FAILED'
2022-03-13T12:28:53.072762+00:00 app[worker.1]: }
2022-03-13T12:28:53.072766+00:00 app[worker.1]: 
2022-03-13T12:28:53.072766+00:00 app[worker.1]: Node.js v17.7.1
2022-03-13T12:28:53.205192+00:00 heroku[worker.1]: Process exited with status 1

每当我启动我的 heroku 应用程序时,它就会崩溃并出现上述错误 我不明白为什么要这样做,这个机器人完全可以正常工作 运行 它关闭了 vscode

根据这个问题 => ,发生错误是因为您已将 node_modules 文件夹提交到您的存储库。 node_modules 文件夹包含您安装的所有模块,其中一些与 Heroku 不兼容。所以你所要做的就是从你的存储库中删除它并通过执行以下操作取消跟踪 node_modules 文件夹:

git rm -r --cached node_modules
git commit -m "Remove node_modules from repository"
git push heroku master