【问题标题】:NPM in GitHub Actions Env not installing packagesGitHub Actions Env 中的 NPM 未安装包
【发布时间】:2021-10-23 11:58:11
【问题描述】:

我有一个使用 discord.js-commando 开发版本的 discord.js 机器人的存储库。

这意味着它会克隆 discordjs/Commando 而不是安装包。

我面临一个问题,由于某种原因 GitHub Actions 无法做到这一点:(

该项目应在任何机器上的 nodejs v12+ 上。我猜是安装包的时候出错了。

这是工作流运行日志:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/discordjs/Commando.git
npm ERR! 
npm ERR! Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! 
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-08-23T03_19_01_561Z-debug.log
Error: Process completed with exit code 1.

这是 package.json:

{
  "name": "alphasians-aina",
  "version": "0.0.0",
  "description": "Alphasians AINA",
  "keywords": [],
  "homepage": "https://github.com/Alphasians/AINA",
  "bugs": {
    "url": "https://github.com/Alphasians/AINA/issues"
  },
  "license": "MIT",
  "contributors": [],
  "main": "src/index.js",
  "bin": {},
  "man": [],
  "directories": {
    "src": "src",
    "lib": "dist"
  },
  "repository": "github:Alphasians/AINA",
  "scripts": {
    "start": "node .",
    "prepare": "husky install",
    "commit": "npx --no-install cz",
    "lint": "npx eslint .",
    "lint:fix": "npx eslint . --fix"
  },
  "dependencies": {
    "@discordjs/opus": "^0.5.3",
    "cheerio": "^1.0.0-rc.10",
    "discord.js": "^12.5.3",
    "discord.js-commando": "github:discordjs/Commando",
    "dotenv": "^10.0.0",
    "ffmpeg-static": "^4.4.0",
    "require-all": "^3.0.0",
    "sequelize": "^6.6.5",
    "simple-youtube-api": "^5.2.1",
    "sqlite": "^4.0.23",
    "ytdl-core": "^4.9.1"
  },
  "devDependencies": {
    "@types/node": "^16.4.13",
    "commitizen": "^4.2.4",
    "cz-conventional-changelog": "^3.3.0",
    "eslint": "^7.30.0",
    "eslint-config-standard": "^16.0.3",
    "eslint-plugin-import": "^2.23.4",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^5.1.0",
    "husky": "^7.0.0"
  },
  "engines": {},
  "publishConfig": {
    "access": "public",
    "registry": "https://registry.npmjs.org/",
    "tag": "latest"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}

【问题讨论】:

  • 请在您的问题中添加必要的信息,而不是指向外部网站的链接
  • James,我实际上已经链接到工作流运行,因为它是与 gh 操作相关的问题...不确定您所说的必要信息是什么意思,所有内容都包含在基于段落的方法中跨度>
  • 就像我说的,回答问题所需的信息应该在问题中。实际上没有链接到任何地方。链接将来可能(并且很可能会)断开,从而使此类问题变得毫无用处。
  • 已修复!让我知道我可以做些什么来改善问题

标签: github npm npm-install github-actions


【解决方案1】:

在将npm ci 命令从package.json 文件中删除之后,我在npm ci 命令之前的另一个步骤中手动更​​新了your workflow file 并更新了discord.js-comando

      - run: npm install discord.js@12 discord.js-commando

      - name: Install Dependencies
        run: npm ci

工作流运行成功。

【讨论】:

  • 我应该如何从工作代码中找到我的问题的答案?不工作的代码在开发分支中?
  • 我刚刚更新了您在工作流运行中使用的工作流文件,该文件返回了您所说的错误。即使在阅读了上面的 cmets 之后,我也不确定问题出在 package.json 中,所以我在我的分叉存储库上尝试了一些东西,这是我找到的使工作流成功运行的解决方案。如果你愿意,我可以开 PR。
  • 其实你在主分支上跑了代码,但是在develop分支上代码错了,所以你的代码还是报错:(
  • 好的,我会检查develop 分支(你应该用这个信息来回答这个问题)???
  • 我找到了一种解决方法,从 develop 分支的 package.json 文件中删除 discord.js-comando,然后在工作流文件中手动安装它。我更新了我的答案。你能检查一下它现在是否有效吗?
猜你喜欢
  • 2019-05-05
  • 2023-03-25
  • 2021-11-24
  • 2020-04-06
  • 1970-01-01
  • 2020-01-14
  • 1970-01-01
  • 1970-01-01
  • 2021-05-20
相关资源
最近更新 更多