Help regarding "Build a JS Command Line Application using Node JS"

Hello all,

I was following along Lukas White and James Hibbard tutorial on "creating a command line application using Node.js " and the overall experience was fun and learned a lot of new things. I would like to thank Lukas and James for easy to follow tutorial and the guide.

Here is the link to the tutorial : Create a console app with Node.js

I followed along all the way until the final application was running. Now the problem is when I create a new Repo via command-line, it asks me whether it’s a public or private and if I choose any option the program crashes with the message below:

"Error: Permission denied (publickey)."
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.  

It creates the new repo on the github account but crashes the program. From the error I get, it is pretty much evident that the crash is due to an Unhandled Promise and probably due to some error in token or something but since I’m not an advanced Node developer, I cannot figure out what actually is going on.

If anybody could help me through this, it would be such a great help.

Also if authors are here in this forum, I would be glad to know your say on it.

Thank you


Could you try cloning the complete article code from GitHub and running that.
I just did so and was able to create a repo without any errors.

git clone
cd ginit
rm -rf .git
node index.js

You’ll need to delete the .git folder, as otherwise the CLI will complain that you’re already in a repo.

Hello James,

Thank you for your reply. Here is the image of what my error looks like even after cloning the repo you mentioned.

Looks like I made some mistake while coding or something ?

Ah ok, I see what is happening.
In repo.js the remote URL is being determined thus:

const response = await github.repos.createForAuthenticatedUser(data);

The ssh_url property on the response will be in the following form:<your-username>/<repo-name>.git.

You can check this by typing git remote -v in your project root directory.

As the variable name suggests, this is a SSH URL. These provide access to a Git repository via SSH, a secure protocol. To use these URLs, you must generate an SSH keypair on your computer and add the public key to your GitHub account.

I’m guessing you don’t have this set up, which is why the final step is failing.

The easiest thing to do at this point would be to set up SSH on your account. Here’s how:

This also has the advantage that you don’t have to enter your credentials when pushing to GitHub.

Alternatively, you could alter the code like so:

const response = await github.repos.createForAuthenticatedUser(data);

But this will require you to input your username and password again. It will also choke if you have 2fa enabled.

HTH. Let me know how you get on.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.