【问题标题】:Code on Heroku deployed, but not installed DependenciesHeroku 上的代码已部署,但未安装
【发布时间】:2020-05-08 06:55:55
【问题描述】:

我尝试将我的 Discord JS 应用程序部署到 Heroku。部署后,节点似乎已经安装了所有依赖项。但是在应用程序日志上,它在那里丢失了。

这是我最新的构建日志

-----> 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):  10.16.3
       engines.npm (package.json):   6.9.0

       Resolving node version 10.16.3...
       Downloading and installing node 10.16.3...
       npm 6.9.0 already installed with node

-----> Restoring cache
       - node_modules (not cached - skipping)

-----> Installing dependencies
       Installing node modules (package.json)
       up to date in 0.303s
       found 0 vulnerabilities


-----> Build

-----> Caching build
       - node_modules (nothing to cache)

-----> Pruning devDependencies
       up to date in 0.282s
       found 0 vulnerabilities


-----> Build succeeded!
-----> Discovering process types
       Procfile declares types     -> worker
       Default types for buildpack -> web
-----> Compressing...
       Done: 19.3M
-----> Launching...
       Released v15
       https://botcia-discordjs.herokuapp.com/ deployed to Heroku

我认为部署似乎没有任何问题。但后来我的应用程序日志出现错误,因此机器人无法启动。

2020-01-22T06:47:36.137591+00:00 heroku[worker.1]: State changed from crashed to starting
2020-01-22T06:47:37.772565+00:00 heroku[worker.1]: Starting process with command `node main.js`
2020-01-22T06:47:38.336892+00:00 heroku[worker.1]: State changed from starting to up
2020-01-22T06:47:39.738190+00:00 heroku[worker.1]: State changed from up to crashed
2020-01-22T06:47:39.721156+00:00 heroku[worker.1]: Process exited with status 1
2020-01-22T06:47:39.657493+00:00 app[worker.1]: internal/modules/cjs/loader.js:638
2020-01-22T06:47:39.657520+00:00 app[worker.1]:     throw err;
2020-01-22T06:47:39.657522+00:00 app[worker.1]:     ^
2020-01-22T06:47:39.657523+00:00 app[worker.1]: 
2020-01-22T06:47:39.657525+00:00 app[worker.1]: Error: Cannot find module 'discord.js'
//more error

实际上发现的第一个错误是找不到模块的东西。因此,如果我设法修复了 discord.js,我会遇到另一个问题。 我的package.json 文件:

{
  "name": "xxxxx",
  "version": "1",
  "main": "main.js",
  "license": "MIT",
  "scripts": {
    "start": "node main.js"
  },
  "dependencies": {
    "discord.js": "^11.5.1",
    "dotenv": "^8.2.0",
    "fs": "^0.0.1-security",
    "moment": "^2.24.0",
    "youtube-info": "^1.3.2"
  },
  "engines": {
    "node": "10.16.3",
    "npm": "6.9.0"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/xxxx/xxxx"
  },
  "author": "XXXX <xxxxxxxxx@gmail.com>",
  "private": false
}

Procfile文件:

worker: node main.js

requirements.txt文件:

npm install discord.js

请注意,我在其网站上使用 GUI 而非 CLI 部署服务器。所以我不知道如何在没有 CLI 的情况下解决它。

【问题讨论】:

标签: node.js heroku discord.js


【解决方案1】:

您只需要部署应用程序,然后在 CLI 中输入 npm install。它将安装 package.json 中定义的所有包。

【讨论】:

    猜你喜欢
    • 2022-01-16
    • 1970-01-01
    • 2019-08-07
    • 1970-01-01
    • 1970-01-01
    • 2021-08-08
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    相关资源
    最近更新 更多