GitHub在GitHub企业中的行动在NPM套餐上提供401和404 [英] GitHub action in GitHub Enterprise giving 401 and 404s on npm packages

查看:11
本文介绍了GitHub在GitHub企业中的行动在NPM套餐上提供401和404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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
' +
    '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
'

我使用的操作不会将任何内容发布到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 }}

请注意,我已填写了@yrshaikh:registry=https://npm.pkg.github.com中的GITHUBCOM_TOKEN@yrshaikh:registry=https://npm.pkg.github.com中的GITHUBCOM_TOKENGITHUBCOM_TOKEN中的GITHUBCOM_TOKENGITHUBCOM_TOKEN

进行这些更改后,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
' +
    '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
'
}

如有任何帮助或指示,我们将不胜感激。

推荐答案

~/.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提供什么?

这篇关于GitHub在GitHub企业中的行动在NPM套餐上提供401和404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆