Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't publish a new package to GitHub Packages #220

Closed
Nawias opened this issue Nov 6, 2024 · 2 comments
Closed

Can't publish a new package to GitHub Packages #220

Nawias opened this issue Nov 6, 2024 · 2 comments

Comments

@Nawias
Copy link

Nawias commented Nov 6, 2024

Hi, I tried using this action to publish a basic package for the first time, but it didn't work; the action claims that it didn't find the package in the registry - which is fair, because it doesn't exist yet.

Error: NpmCallError: Call to "npm publish" exited with non-zero exit code 1
npm notice Publishing to https://npm.pkg.github.com/ with tag latest and default access
npm error code E404
npm error 404 Not Found - PUT https://npm.pkg.github.com/nestlink-lib
npm error 404
npm error 404  'nestlink-lib@0.8.0' is not in this registry.
npm error 404
npm error 404 Note that you can also install from a
npm error 404 tarball, folder, http url, or git url.
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2024-11-06T12_54_14_260Z-debug-0.log

I've read through a couple of other issues here, but didn't find a solution - apart from "it's fixed in the latest PR" comments here and there. Maybe the bug reappeared since then?
Here's my workflow file:

name: Publish package to GitHub Packages
on:
    release:
        types: [published]

jobs:
    publish:
      runs-on: ubuntu-latest
      permissions:
        contents: read
        packages: write # allow GITHUB_TOKEN to publish packages
      steps:
        - uses: actions/checkout@v4
        - uses: actions/setup-node@v3
          with:
            node-version: "20"
        - run: npm ci
        - run: npm run build
        - uses: JS-DevTools/npm-publish@v3
          with:
            token: ${{ secrets.GITHUB_TOKEN }}
            registry: "https://npm.pkg.github.com"

Here's a link to the latest action run: https://github.com/Nawias/nestlink-lib/actions/runs/11703955074/job/32595369991
And to my repository in general: https://github.com/Nawias/nestlink-lib

I would appreciate any help, thank you!

@mcous
Copy link
Member

mcous commented Nov 6, 2024

Hi @Nawias! A 404 during npm publish typically indicates a permission error or that your package.json is malformed or missing important information. In your case, I believe it is because your package's name field is not scoped to your GitHub username:

GitHub Packages only supports scoped npm packages. Scoped packages have names with the format of @NAMESPACE/PACKAGE-NAME. Scoped packages always begin with an @ symbol. You may need to update the name in your package.json to use the scoped name. For example, if you're the user octocat and your package is named test, you would assign the scoped package name as follows: "name": "@octocat/test".

Source: Publishing a Package

@Nawias
Copy link
Author

Nawias commented Nov 6, 2024

Thank you so much! That did the job. I'm sorry for making an issue out of this, should've RTFM.

@Nawias Nawias closed this as completed Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants