`.env.development` is not read by `gatstby-config.js`
Expected behavior
.env.developmentand.env.productionfiles are read at the top ofgatsby-config.jsand thenpm startprocess kicks off normally
Actual behavior
- Those files are not read, and the
GITHUB_APIvalue isundefinedleading to a Bad Credentials error.
Steps to reproduce the problem
- If you have
GITHUB_APIdefined anywhere else (e.g. in a.envrc,.bashrcor.zshrc, remove/comment out that line - Add a valid GitHub API token to
.env.developmentand/or.env.production - Run
npm startornpm run develop - Get the error
I put console.log around the dotenv processing at the beginning of gatsby-config.js on my local and found that it is being processed. I don't know what the discrepancy is between your machine and my machine. This might be a good excuse to explore GitHub Codespaces for local(ish) developement.
Codespaces would at least eliminate the "works/doesn't work on my machine" issue. We can icebox this if no one can reproduce, but...
I put console.log around the dotenv processing at the beginning of gatsby-config.js on my local
Did you also check to see if you have a GITHUB_API variable defined in your .zshrc or relevant Bash .*rc file? That ended up being the fix for me and I already had a GITHUB_TOKEN defined in there for other things.
Not resolved, but workarounds achieved so we're opt'ing to close