Npm install private repo

I’m trying to npm install a package.json that contains a module that is a private Github module.

I have generated a personal access token with repo privileges and added that as a secret.

Then in package.json the private repo module dependency looks like this:

"<module-name>": "git+https://$PERSONAL_ACCESS_TOKEN:x-oauth-basic@github.com/[username]/[repo-name].git"

The action runs and the logs show the env variable is being set in the workflow step:

PERSONAL_ACCESS_TOKEN: ***

However I’m getting this error in the GitHub action:

npm ERR! Error while executing:

npm ERR! /usr/bin/git ls-remote -h -t ***github.com/[username]/[repo-name].git

npm ERR!

npm ERR! remote: Repository not found.

npm ERR! fatal: repository ‘https://github.com/[username]/[repo-name].git/’ not found

npm ERR! exited with error code: 128

When I copy and paste the url into a browser, the repo is definitely there as it loads in the browser.

What am I missing?

1 Like

By the way…

I got the syntax from this SO post: