代码之家  ›  专栏  ›  技术社区  ›  David Faizulaev

Github-尝试将包发布到npm时出现找不到错误

  •  0
  • David Faizulaev  · 技术社区  · 4 年前

    我有以下工作流程:

    # 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!)
    

    请告知我如何解决此问题。

    0 回复  |  直到 4 年前
        1
  •  0
  •   OriEng    4 年前

    npm login 在这里没有必要。

    1. 在上配置作业 yml 文件:

      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v3
        - uses: actions/setup-node@v3
          with:
            node-version: 16
            registry-url: 'https://registry.npmjs.org'
        - run: npm ci
        - run: npm run build
        - run: npm publish
          env:
            NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
      
    2. 定义 NPM_TOKEN 访问令牌 npmjs 访问令牌下的帐户,确保它是 自动化 令牌:

    enter image description here

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

      enter image description here