【问题标题】:Github - getting not found error when trying to publish package to npmGithub - 尝试将包发布到 npm 时出现未找到错误
【发布时间】:2022-06-22 23:50:17
【问题描述】:

我正在尝试将一个新包发布到 npm,public。

我有以下工作流程:

# This workflow will run tests using node and then publish a package to GitHub 

Packages 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:
  release:
    types: [created]

jobs:

  publish-npm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 14
          registry-url: https://registry.npmjs.org/
      - run: npm ci
      - run: npm login
      - run: npm config set access public
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.npm_token}}

但我收到以下错误:

npm notice 
npm notice ????  @orgname/pdf-image@1.2.2
npm notice === Tarball Contents === 
npm notice 135B    Dockerfile                       
npm notice 135B    Dockerfile12                     
npm notice 1.1kB   LICENSE                          
npm notice 6.8kB   index.js                         
npm notice 5.9kB   tests/test-main.js               
npm notice 530B    package.json                     
npm notice 2.1kB   README.md                        
npm notice 325.2kB tests/test.pdf                   
npm notice 1.1kB   .github/workflows/node.js.yml    
npm notice 664B    .github/workflows/npm-publish.yml
npm notice === Tarball Details === 
npm notice name:          @orgname/pdf-image                    
npm notice version:       1.2.2                                   
npm notice package size:  322.6 kB                                
npm notice unpacked size: 343.6 kB                                
npm notice shasum:        d362e3a6c95d12b2329ed608495c45580bb8de15
npm notice integrity:     sha512-OpurprtbmR7By[...]V553ykjYtaOrA==
npm notice total files:   10                                      
npm notice 
npm ERR! code E404
npm ERR! 404 Not Found - PUT https://registry.npmjs.org/@orgname%2fpdf-image - Not found
npm ERR! 404 
npm ERR! 404  '@orgname/pdf-image@1.2.2' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)

请告知我该如何解决这个问题。

【问题讨论】:

  • 您是否需要将@orgname 替换为您的实际组织名称?还是您添加它是为了混淆您的组织名称 SO?
  • 仅用于混淆目的。
  • 相同的命令在本地工作吗?
  • 没有尝试,考虑过,但希望从工作流中释放第一个标签。

标签: github-actions npm-publish


【解决方案1】:

npm login 在这里是不必要的。 您需要执行 3 个步骤才能使其工作:

  1. 在您的 yml 文件中配置作业:

    发布-npm: 运行:ubuntu-latest 脚步: - 使用:actions/checkout@v3 - 使用:actions/setup-node@v3 和: 节点版本:16 注册网址:'https://registry.npmjs.org' - 运行:npm ci - 运行:npm 运行构建 - 运行:npm 发布 环境: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

  2. 在您的npmjs 帐户的访问令牌下定义NPM_TOKEN 访问令牌,确保它是一个自动化 令牌:

  1. 复制此令牌并在您的 GitHub 存储库中定义他:

【讨论】:

    猜你喜欢
    • 2016-12-31
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 2020-08-23
    • 2023-03-18
    • 2021-11-02
    • 1970-01-01
    • 2019-06-19
    相关资源
    最近更新 更多