Github操作:找不到NPM发布404

问题描述

在我的github项目中,我试图自动创建一个新版本,并在将任何内容推送到master分支时将其发布到NPM。

想法

  1. 创建新的次要版本
  2. 将该软件包发布到NPM

我正在使用github动作。我的工作流程文件如下:

# This workflow will run tests using node and then publish a package to the npm registry when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
#trigger on every commit to the main branch
  push:
    branches:
      - main
      - master 

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm test

  publish-npm:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/
      - run: git config user.name $GITHUB_ACTOR
      - run: git config user.email gh-actions-${GITHUB_ACTOR}@github.com
      - run: git remote add gh-origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
      - run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
      - run: npm version patch
      - run: npm publish
      - run: git push gh-origin HEAD:master --tags
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

https://github.com/ether/ep_align/actions/runs/322527776

发布时,我不断收到404错误。我不了解,因为该软件包在线位于:https://www.npmjs.com/package/ep_align

npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/ep_align - Not found
npm ERR! 404 
npm ERR! 404  'ep_align@0.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.

这个问题现在让我发疯了几个小时,我不知道可能是什么。 有什么想法吗?

解决方法

这只是您的令牌的身份验证问题。

您是否曾在 Repository secrets 中设置访问令牌? (您可能还想创建环境。)

https://docs.npmjs.com/creating-and-viewing-access-tokens

或者也可能是授权问题。请检查您的令牌类型。它应该是自动化的。

这是我的一个例子> https://github.com/canberksinangil/canberk-playground

我在存储库设置下设置令牌的位置。 enter image description here

让我知道这是否有帮助:)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...