简体   繁体   中英

I'm trying to create a discord bot with Heroku, when I run it locally it works, but it doesn't work when I deploy it on Heroku

When I run index.js locally, it works. When I try to deploy the code on Heroku, this is the error that I recieve.

2022-01-11T05:25:24.034595+00:00 app[worker.1]:     at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-01-11T05:25:24.034595+00:00 app[worker.1]:     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-01-11T05:25:24.034595+00:00 app[worker.1]:     at Module.load (node:internal/modules/cjs/loader:981:32)
2022-01-11T05:25:24.034595+00:00 app[worker.1]:     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-01-11T05:25:24.034595+00:00 app[worker.1]:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
2022-01-11T05:25:24.034596+00:00 app[worker.1]:   code: 'MODULE_NOT_FOUND',
2022-01-11T05:25:24.034596+00:00 app[worker.1]:   requireStack: [ '/app/index.js' ]
2022-01-11T05:25:24.034596+00:00 app[worker.1]: }
2022-01-11T05:25:24.156241+00:00 heroku[worker.1]: Process exited with status 1
2022-01-11T05:25:24.201235+00:00 heroku[worker.1]: State changed from up to crashed

Contents of package.json

{
  "dependencies": {
    "discord.js": "^13.5.1"
  },
  "engines": {
    "node": "16.13.1"
  },
  "name": "yourstickers-bot",
  "version": "1.0.0",
  "main": "index.js",
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/TheBread-Master/yourstickers-bot.git"
  },
  "author": "Bread",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/TheBread-Master/yourstickers-bot/issues"
  },
  "homepage": "https://github.com/TheBread-Master/yourstickers-bot#readme",
  "description": ""
}

I ran npm init and it still didn't work.

You need to edit your scripts. add

"start": "node server.js"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM