【问题标题】:Error around package files for Node.js Discord botNode.js Discord 机器人的包文件错误
【发布时间】:2020-10-25 03:54:42
【问题描述】:

我有一个基本的 Discord 机器人,我正在尝试通过 Heroku 发布,因为我不能再在本地托管它了。 应该提到它在我的虚拟机上本地托管时运行得非常好。 当尝试通过 cli 或 git 推送到 Heroku 时,我收到一条错误消息:

npm 错误! cipm 只能在您的 package.json 和 package-lock.json 或 npm-shrinkwrap.json 同步时安装包。请在继续之前使用npm install 更新您的锁定文件。 远程:npm 错误! 远程:npm 错误! 远程:npm 错误!缺少:enmap@^5.2.4 远程:npm 错误!缺少:eslint@^7.2.0

尝试了谷歌搜索,但仍然不知道这些包文件是如何工作的,所以如果有人能告诉我要更改什么,将不胜感激。

package.json

{
  "name": "sidbot2",
  "version": "2.3.2",
  "description": "",
  "main": "sidbot.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "sidilleth",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^12.2.0",
    "enmap": "^5.2.4"
    "eslint": "^7.2.0"
  },
  "devDependencies": {
    "eslint": "^7.2.0"
  }
}

【问题讨论】:

  • 我还应该提到我已经按照建议运行了 npm install 命令,但我仍然收到错误
  • 欢迎来到 Stackoverflow。请在问题本身中添加您的所有代码并阅读How to create a Minimal, Reproducible ExampleHow do I ask a good question? 并相应地编辑您的问题。
  • 我没有在问题中包含代码,因为它非常长,并且没有“在它起作用之前取出位”,因为需要包文件中的所有数据?真的不能让我的问题更清楚吗?
  • 我建议你编辑你的问题并添加package.json的内容。 package-lock.json 不是必需的,您可以删除它。

标签: node.js heroku npm discord discord.js


【解决方案1】:

dependencies 中删除eslint,因为它已经存在于dev dependencies 中。它应该看起来像这样:

{
  "name": "sidbot2",
  "version": "2.3.2",
  "description": "",
  "main": "sidbot.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "sidilleth",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^12.2.0",
    "enmap": "^5.2.4"
  },
  "devDependencies": {
    "eslint": "^7.2.0"
  }
}

删除node_modules文件夹并执行npm install

还要确保在package.jsonpackage-lock.json 中所做的所有更改都已提交到git。

【讨论】:

    猜你喜欢
    • 2019-01-12
    • 2020-04-07
    • 2021-08-14
    • 2018-07-24
    • 2018-10-10
    • 2022-11-27
    • 2019-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多