I’m trying to publish an Angular library using GitHub Actions, but I’m encountering an error related to SSH authentication. Despite my repository being public, the npm publish command fails with the following error message:
npm error code 128
npm error An unknown git error occurred
npm error command git --no-replace-objects ls-remote ssh://[email protected]/dist/ngx-otp-input.git
npm error [email protected]: Permission denied (publickey).
npm error fatal: Could not read from remote repository.
npm error
npm error Please make sure you have the correct access rights
npm error and the repository exists.
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2024-07-18T05_51_37_041Z-debug-0.log
Error: Process completed with exit code 128.
I have already checked similar questions on Stack Overflow, and this solution has been mentioned multiple times. However, I’m unsure if it applies to my case, as I am working with a public repository.
Here is the relevant part of my workflow:
steps:
# clone, install dependencies, build
- name: '🚀 Publish'
run: npm publish dist/ngx-otp-input --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
You can find the full CI file that attempts to publish the library here.
Apparently npm
interprets dist/ngx-otp-input
as a GitHub repository in the format organization/repository
. As a consequence, npm tries to clone this repository. However this repository does not exist, and it’s not what you want to do.
What you actually want is to publish the local folder. So try prefixing your path with ./
to indicate npm
that you want to do work with local folders:
npm publish ./dist/ngx-otp-input
1
To resolve this issue, you’ll need to set up SSH keys for GitHub Actions so that it can authenticate with GitHub over SSH.screenshot of how to set ssh key
STACKOVERFLOW Illuminati is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3