Heroku Node.js Discord.js 机器人部署失败

Heroku Node.js Discord.js bot deployment failed

我遇到了很多问题。我创建了一个本地 git 存储库,将推荐设置设置为 adviced here,并将机器人使用的所有文件复制到该存储库中。然后我添加了所有文件,提交了更改并将其推送到 Heroku 存储库中。但是没有 GitHub 存储库。我有一个非常重要的原因不创建 GitHub 存储库,因为机器人令牌位于配置 JSON 文件中,该文件实际上是源代码的一部分。我不希望该标记在 public.

中可见

然而,事情并没有很好地结束。 Heroku 日志显示应用程序崩溃是因为没有设置入口点。只能猜测是服务端app配置有误,或者传输文件时出错。我能以某种方式恢复应用程序吗?还是我需要制作全新的应用程序并独立地一个一个安装所有部分?

Heroku 日志是这样写的:

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

我似乎找不到问题的根源。这是 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"
  }
}

对应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" 的脚本。通常,"start" 脚本仅表示“node *file_name*”。
在您的 package.json 文件中,添加
"scripts": { "start": "node *your main app filename*", } 你的"Installing everything again"问题呢,我不太明白。尝试添加我提到的脚本,将它们提交给 git,看看它是否能解决问题。