首页 > 解决方案 > 在 Github Action 中,如何将私有包发布到使用私有依赖项的 NPM?

问题描述

试图在 Github 组织中了解如何使用私有组织的依赖项并使用 Github Action 发布另一个私有包,但它在 Actions 中出错:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@wilson%monday - Not found
npm ERR! 404 
npm ERR! 404  '@wilson/monday@latest' 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 It was specified as a dependency of 'tuesday'
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.yml文件:

name: npm
on:
  release:
    types: [published]
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12.x]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '12.x'
          registry-url: 'https://registry.npmjs.org'
      - run: npm install
      - run: npm ci --ignore-scripts
      - run: npm run build --if-present
      - run: npm publish
        env:
          CI: true
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

我也尝试更改registry-url为:

registry-url: 'https://npm.pkg.github.com'

包.json

  "name": "@wilson/tuesday",
  "version": "1.3.7"
  "publishConfig": {
    "access": "restricted",
    "registry": "https://npm.pkg.github.com/wilson/"
  },
  "dependencies": {
    "@wilson/monday": "latest",
  },

我能找到与此相关的最接近的问题:“如何在私有组织仓库中发布带有 github 操作的私有 github 包? ”。

基于这个答案,我假设我的存储库中不需要 .npmrc 。

关于该主题的进一步研究:

在我的 Github Action 中,如何将私有包发布到使用私有依赖项的 NPM?

标签: node.jsnpmgithub-actions

解决方案


推荐阅读