Search code examples
npmdeploymentenvironment-variablesgithub-pagesdocusaurus

Please set the GIT_USER environment variable or explicitly specify USE_SSH


I'm encountering an issue while trying to deploy my Docusaurus site using the npm run deploy command. Here's the error message I'm getting:

Please set the GIT_USER environment variable or explicitly specify USE_SSH

OR

Error: Please set the GIT_USER environment variable, or explicitly specify USE_SSH instead!

I'm using Docusaurus version 3.1.1 and Node version v20.10.0. Below is the full error log:

[WARNING] When deploying to GitHub Pages, it is better to use an explicit "trailingSlash" site config.
Otherwise, GitHub Pages will add an extra trailing slash to your site urls only on direct-access (not when navigation) with a server redirect.
This behavior can have SEO impacts and create relative link issues.

[INFO] Deploy command invoked...

Error: Please set the GIT_USER environment variable, or explicitly specify USE_SSH instead!
    at Command.deploy (F:\personal-sites\code-harbor-hub\node_modules\@docusaurus\core\lib\commands\deploy.js:70:19)

[INFO] Docusaurus version: 3.1.1
Node version: v20.10.0

I've tried troubleshooting by checking my environment variables, but I can't seem to resolve this issue. Can someone please guide me on how to fix this error and successfully deploy my Docusaurus site?


Solution

  • It appears you are set up to deploy to GitHub and as such that requires you to have a GitHub user set so it knows where to deploy to. Depending on your environment you need to set that environment variable before running the command:

    export GIT_USER=yourusername