I'm new to GitHub Packages (or publishing NPM packages in general) and am trying to publish packages to my private repository using semantic release following this excellent blog post.
However, I'm running into issues authenticating with GitHub Packages when trying to submit my build artifacts. I'm looking for pointers on where I'm going wrong.
npm ERR! 403 403 Forbidden - PUT https://npm.pkg.github.com/@thijsfranck%2fexample - Permission not_found: owner not found\n
Not quite sure where I'm going wrong, but I would have expected the request to be made to my GitHub repository rather than https://npm.pkg.github.com
. Is the request going to the right place?
For context, here is the step in my GitHub Actions flow that is supposed to publish my packages but instead produces the above error. I have set the referenced secrets in my GitHub repository.
- name: Release
if: ${{ success() && (github.event_name != 'pull_request' || github.event.action == 'closed' && github.event.pull_request.merged == true) }}
env:
GITHUB_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npx nx affected --target release
Next is the release
executor for my Nx repository:
"release": {
"executor": "nx:run-commands",
"outputs": [],
"options": {
"command": "npx semantic-release-plus --debug --extends ./example/release.config.js",
"parallel": false
}
},
And finally my package.json
:
{
"name": "@thijsfranck/example",
"version": "0.0.0-semantic-release",
"type": "commonjs",
"repository": {
"type": "git",
"url": "https://github.com/thijs-franck/example-repo.git",
"directory": "thijsfranck/example"
},
"publishConfig": {
"registry": "https://npm.pkg.github.com"
},
}
Turns out the solution was to ensure the name of the packages starts with the repo owner name. So in this case, package names should start with @thijs-franck/
instead of @thijsfranck/