【问题标题】:GitHub action in GitHub Enterprise giving 401 and 404s on npm packagesGitHub Enterprise 中的 GitHub 操作在 npm 包上提供 401 和 404
【发布时间】:2021-08-25 05:57:54
【问题描述】:

我在我的 GitHub 企业存储库中使用 semantic version action。直到最近它工作正常,它开始以this error 失败

Error: Command failed: npm ci --only=prod
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-23T10_41_00_344Z-debug.log

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'npm ci --only=prod',
  stdout: '',
  stderr: 'npm ERR! code E401\n' +
    'npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"\n' +
    '\n' +
    'npm ERR! A complete log of this run can be found in:\n' +
    'npm ERR!     /root/.npm/_logs/2021-08-23T10_41_00_344Z-debug.log\n'

我使用的操作预计不会向 GitHub 包注册表发布任何内容,可能只会从包注册表中读取。所以在谷歌搜索后,我在 SO 和其他地方找到了这个 - https://stackoverflow.com/a/63243950/1182982

所以我更新了我的操作,现在看起来像这样(我添加了步骤:设置节点,它以前不存在)

#===============================================================================
#===========================      Semamtic Version    ==========================
#===============================================================================
    semver:
        name: Semantic Versioning
        runs-on: [self-hosted, linux, x64]
        steps:
        - name: Setup node
          run: |
            echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUBCOM_TOKEN }}" >> ~/.npmrc
            echo "@yrshaikh:registry=https://npm.pkg.github.com" >> ~/.npmrc
            echo 'registry "https://registry.yarnpkg.com"' >> ~/.yarnrc
        - uses: actions/checkout@v2
        - name: Semantic Release
          id: semantic
          # https://github.com/cycjimmy/semantic-release-action
          uses: internal-front-end/semantic-release-action@v2
        outputs:
          new_release_published: ${{ steps.semantic.outputs.new_release_published }}
          new_release_version: ${{ steps.semantic.outputs.new_release_version }}

注意,GITHUBCOM_TOKEN 我是使用我的 github.com 个人资料创建的(并提供了读取包/repo 访问权限)和@yrshaikh:registry=https://npm.pkg.github.com 中的OWNER_NAME 我已经填写了 github.com 用户 ID。

进行这些更改后,401 身份验证错误消失了。

但我看到一个不同的错误,我无法解决 -

Error: Command failed: npm --loglevel error ci --only=prod
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/@actions%2fcore - npm package "core" does not exist under owner "actions"
npm ERR! 404 
npm ERR! 404  '@actions/core@1.2.7' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-08-25T05_40_28_115Z-debug.log

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'npm --loglevel error ci --only=prod',
  stdout: '',
  stderr: 'npm ERR! code E404\n' +
    'npm ERR! 404 Not Found - GET https://npm.pkg.github.com/@actions%2fcore - npm package "core" does not exist under owner "actions"\n' +
    'npm ERR! 404 \n' +
    "npm ERR! 404  '@actions/core@1.2.7' is not in the npm registry.\n" +
    'npm ERR! 404 You should bug the author to publish it (or use the name yourself!)\n' +
    'npm ERR! 404 \n' +
    'npm ERR! 404 Note that you can also install from a\n' +
    'npm ERR! 404 tarball, folder, http url, or git url.\n' +
    '\n' +
    'npm ERR! A complete log of this run can be found in:\n' +
    'npm ERR!     /root/.npm/_logs/2021-08-25T05_40_28_115Z-debug.log\n'
}

任何帮助或指导将不胜感激。

【问题讨论】:

  • /root/.npm/_logs/2021-08-25T05_40_28_115Z-debug.log 是什么?

标签: github npm npm-install github-actions github-enterprise


【解决方案1】:

~/.npmrc 似乎没有什么问题:

@${OWNER}:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${TOKEN}

您是否尝试过重新生成该个人访问令牌?请注意,这些机密也有范围,因此它们可能会在私有存储库中解析,但不一定是公共存储库。

$GITHUB_TOKEN 可能没有足够的permissions;尝试添加personal access token

npm login --scope=@yrshaikh --registry=https://npm.pkg.github.com 提供了什么?

【讨论】:

    猜你喜欢
    • 2021-01-15
    • 2021-02-05
    • 2022-01-10
    • 2021-10-06
    • 2022-01-25
    • 2020-07-26
    • 2021-10-03
    • 2022-10-21
    • 2021-04-13
    相关资源
    最近更新 更多