node.js - Heroku Node.js Discord.js bot deployment failed
问题描述
I've encountered quite a little bit issue. I've created a local git repositiory, set up recommended settings as adviced here, and copied all files used by the bot into that repository. Then I added all files, commited changes and pushed into Heroku repository. However without the GitHub repository. I have very important reason for not creating GitHub repository as the bot token is inside a configuration JSON file, which is actually part of the source code. I do not want that token to become visible in public.
However, things didn't quite end up well. The Heroku log says the app crashed because there was no entry point set. I can only guess that there was a mistake in app configuration on the server side, or made mistake while transporting files. Can I recover the app somehow? Or do I need to make completely fresh new app and install all parts one by one independently?
This is what Heroku log says:
2018-09-11T13:25:20.012914+00:00 heroku[web.1]: State changed from crashed to starting
2018-09-11T13:25:18.633506+00:00 app[api]: Deploy 338966c1 by user marpolda@gmail.com
2018-09-11T13:25:18.633506+00:00 app[api]: Release v7 created by user marpolda@gmail.com
2018-09-11T13:25:19.000000+00:00 app[api]: Build succeeded
2018-09-11T13:25:26.534154+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-11T13:25:29.260285+00:00 heroku[web.1]: State changed from starting to crashed
2018-09-11T13:25:29.262057+00:00 heroku[web.1]: State changed from crashed to starting
2018-09-11T13:25:29.246814+00:00 heroku[web.1]: Process exited with status 1
2018-09-11T13:25:29.146268+00:00 app[web.1]: npm ERR! missing script: start
2018-09-11T13:25:29.160586+00:00 app[web.1]:
2018-09-11T13:25:29.160933+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-09-11T13:25:29.161118+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-09-11T13_25_29_151Z-debug.log
2018-09-11T13:25:31.267503+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-11T13:25:33.607355+00:00 heroku[web.1]: Process exited with status 1
2018-09-11T13:25:33.617718+00:00 heroku[web.1]: State changed from starting to crashed
2018-09-11T13:25:33.549320+00:00 app[web.1]: npm ERR! missing script: start
2018-09-11T13:25:33.555176+00:00 app[web.1]:
2018-09-11T13:25:33.555439+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-09-11T13_25_33_550Z-debug.log
2018-09-11T13:25:33.555355+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-09-11T14:02:26.829754+00:00 heroku[web.1]: State changed from crashed to starting
2018-09-11T14:02:29.197832+00:00 heroku[web.1]: Starting process with command `npm start`
2018-09-11T14:02:32.177929+00:00 heroku[web.1]: Process exited with status 1
2018-09-11T14:02:32.191335+00:00 heroku[web.1]: State changed from starting to crashed
2018-09-11T14:02:32.092366+00:00 app[web.1]: npm ERR! missing script: start
2018-09-11T14:02:32.099124+00:00 app[web.1]:
2018-09-11T14:02:32.099383+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-09-11T14:02:32.099521+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-09-11T14_02_32_094Z-debug.log
I can't seem to locate the root of the issue. This is package.json
:
{
"name": "notch",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "CZghost",
"license": "ISC",
"dependencies": {
"discord.js": "^11.4.2"
}
}
And corresponding package-lock.json
:
{
"name": "notch",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"discord.js": {
"version": "11.4.2",
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-11.4.2.tgz",
"integrity": "sha512-MDwpu0lMFTjqomijDl1Ed9miMQe6kB4ifKdP28QZllmLv/HVOJXhatRgjS8urp/wBlOfx+qAYSXcdI5cKGYsfg==",
"requires": {
"long": "^4.0.0",
"prism-media": "^0.0.3",
"snekfetch": "^3.6.4",
"tweetnacl": "^1.0.0",
"ws": "^4.0.0"
}
},
"long": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
},
"prism-media": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-0.0.3.tgz",
"integrity": "sha512-c9KkNifSMU/iXT8FFTaBwBMr+rdVcN+H/uNv1o+CuFeTThNZNTOrQ+RgXA1yL/DeLk098duAeRPP3QNPNbhxYQ=="
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"snekfetch": {
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/snekfetch/-/snekfetch-3.6.4.tgz",
"integrity": "sha512-NjxjITIj04Ffqid5lqr7XdgwM7X61c/Dns073Ly170bPQHLm6jkmelye/eglS++1nfTWktpP6Y2bFXjdPlQqdw=="
},
"tweetnacl": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz",
"integrity": "sha1-cT2LgY2kIGh0C/aDhtBHnmb8ins="
},
"ws": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
"integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
"requires": {
"async-limiter": "~1.0.0",
"safe-buffer": "~5.1.0"
}
}
}
}
解决方案
它说2018-09-11T14:02:32.177929+00:00 heroku[web.1]: Process exited with status 1
2018-09-11T14:02:32.191335+00:00 heroku[web.1]: State changed from starting to crashed
2018-09-11T14:02:32.092366+00:00 app[web.1]: npm ERR! missing script: start
这意味着它正在你的 package.json 文件中寻找一个名为“start”的脚本。通常,“开始”脚本仅表示“ node *file_name*
”。
在你的 package.json 文件中,添加
"scripts": {
"start": "node *your main app filename*",
}
关于“再次安装所有内容”的问题,我不太明白。尝试添加我提到的脚本,将它们提交到 git 并查看它是否可以解决问题。
推荐阅读
- python - 如何使用scrapy和selenium解析加载缓慢的网页?
- python - Python Logger 类不打印日志的实现
- java - Java - XML 到 JSON 的转换(org.json.JSONException: Mismatched meta and head at character 573)
- java - Null Safe 比较具有 0.0 和 0 的两个 bigdecimal 对象
- laravel - Laravel 从聊天表中获取最后一条消息
- java - JavaFX 应用程序自定义方案 URI 处理程序
- python - ND 卷积反向传播
- c++ - 默认文件名在 Windows IFileDialog 中出现截断
- python - 使用 uvicorn 在同一线程中运行多个 asgi 应用程序
- node.js - 如何模拟“TLS 握手超时”[ERR_TLS_HANDSHAKE_TIMEOUT] 超时错误?