无法构建引用已在 github 中发布的包的 github 包

问题描述 投票:0回答:1

我们有两个存储库,每个存储库都包含一个角度库

  1. lib_a
  2. lib_b(使用包lib_a

lib_a 在 git-hub 包中构建并发布(版本 0.0.4)

问题在于构建lib_b(这是工作流程操作的输出):

build.yml如下

name: "Build package"
on:
  push:
  workflow_dispatch:
jobs:
  build:
    runs-on:
      - ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup Node.js environment
        uses: actions/[email protected]
        with:
          registry-url: 'https://npm.pkg.github.com'
          scope: '@app'
      - name: Build
        env:
          NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          npm install
          npm run build
          cd dist/lib_b && npm publish
 

Run npm install
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm error code E403
npm error 403 403 Forbidden - GET https://npm.pkg.github.com/download/@app/lib_a/0.0.4/82727a643d29921f0d18d3ba84e7aef5fb9daea9 - Permission permission_denied: read_package
npm error 403 In most cases, you or one of your dependencies are requesting
npm error 403 a package version that is forbidden by your security policy, or
npm error 403 on a server you do not have access to.

npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2024-08-27T07_36_05_595Z-debug-0.log
Error: Process completed with exit code 1.
angular github npm package
1个回答
0
投票

在项目 (package.json) 位置的根目录中,创建一个

.npmrc
文件。在其中设置正确的身份验证注册表,它应该可以工作。

@username:registry = https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken={{token}}

这适用于本地计算机上安装的私有软件包。


对于 github 操作,您可以尝试指定 npm 令牌,您可以使用本指南进行配置

steps:
  - run: |
      npm install
  - env:
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
© www.soinside.com 2019 - 2024. All rights reserved.