我希望你能帮助我。我尝试在Heroku上部署Discord Bot,但不幸的是,它找不到Discord.js模块:
错误代码:
2019-10-31T15:35:21.569158+00:00 heroku[worker.1]: State changed from crashed to starting
2019-10-31T15:35:23.457399+00:00 heroku[worker.1]: Starting process with command `node Bot.js`
2019-10-31T15:35:24.147895+00:00 heroku[worker.1]: State changed from starting to up
2019-10-31T15:35:25.778631+00:00 heroku[worker.1]: Process exited with status 1
2019-10-31T15:35:25.838621+00:00 heroku[worker.1]: State changed from up to crashed
2019-10-31T15:35:25.715847+00:00 app[worker.1]: internal/modules/cjs/loader.js:797
2019-10-31T15:35:25.715865+00:00 app[worker.1]: throw err;
2019-10-31T15:35:25.715866+00:00 app[worker.1]: ^
2019-10-31T15:35:25.715867+00:00 app[worker.1]:
2019-10-31T15:35:25.715868+00:00 app[worker.1]: Error: Cannot find module 'discord.js'
2019-10-31T15:35:25.715869+00:00 app[worker.1]: Require stack:
2019-10-31T15:35:25.71587+00:00 app[worker.1]: - /app/Bot.js
2019-10-31T15:35:25.715871+00:00 app[worker.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
2019-10-31T15:35:25.715872+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:687:27)
2019-10-31T15:35:25.715873+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:849:19)
2019-10-31T15:35:25.715874+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-10-31T15:35:25.715875+00:00 app[worker.1]: at Object.<anonymous> (/app/Bot.js:6:17)
2019-10-31T15:35:25.715876+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:956:30)
2019-10-31T15:35:25.715877+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
2019-10-31T15:35:25.715878+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:812:32)
2019-10-31T15:35:25.715879+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2019-10-31T15:35:25.715879+00:00 app[worker.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10) {
2019-10-31T15:35:25.715881+00:00 app[worker.1]: code: 'MODULE_NOT_FOUND',
2019-10-31T15:35:25.715882+00:00 app[worker.1]: requireStack: [ '/app/Bot.js' ]
2019-10-31T15:35:25.715883+00:00 app[worker.1]: }
构建日志:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.13.0...
Using default npm version: 6.12.0
-----> Restoring cache
- node_modules (not cached - skipping)
-----> Installing dependencies
Installing node modules (package.json)
up to date in 0.313s
found 0 vulnerabilities
-----> Build
-----> Pruning devDependencies
up to date in 0.275s
found 0 vulnerabilities
-----> Caching build
- node_modules (nothing to cache)
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> worker
Default types for buildpack -> web
-----> Compressing...
Done: 20.8M
-----> Launching...
Released v27
https://omghowadorable.herokuapp.com/ deployed to Heroku
还有我的package.json:
{
"name": "Date Bot",
"description": "My First Discord Bot",
"version": "1.0.0",
"main": "Bot.js",
"scripts": {
"start": "node Bot.js"
}, "dependencies": {
"discord.js": "11.3.0"
}
}
我真的不知道Heroku没有安装Discord.js的package.json文件出了什么问题。谷歌这次也没有真正的帮助。 我希望你能帮助我解决我的问题。
真诚的塔基
答案 0 :(得分:0)
尝试进入Heroku Run命令并输入npm i discord.js