I had a similar issue when deploying with GitHub Pages. I would run npm run deploy
and get the same error.
The tutorial I followed suggested I use an HTTPS URL while setting up my project:
$ git remote add origin https://github.com/git-name/repo-name.git
Instead, I found that using an SSH URL resolved the error:
$ git remote add origin git@github.com:git-name/repo-name.git
While there's a debate on using HTTPS versus SSH, I saw that somebody else had solved a similar issue using SSH URL and tried it myself. Worked like a charm!
To check and change your remote origin, follow these commands:
$ git remote -v
$ git remote set-url origin git@github.com:git-name/repo-name.git