Question: Should .env.development be created with contentful guide?
Expected Behavior
Running contentful guide on macOS 11.6, following all instructions onscreen, including full set up of new account, should result in being able to run npm run dev as instructed by prompts.
Actual Behavior
What happens instead is that I would consistently get:
Error: Contentful spaceId and the access token need to be provided
To fix, I had to do a few manual steps:
- Create API tokens in my account in Settings > API Tokens.
- Create a new
.env.developmentfile in my root sample gatsby project folder created withcontentful guide. - Enter the
CONTENTFUL_SPACE_IDandCONTENTFUL_ACCESS_TOKENvalues and save the file. - Re-run
npm run dev. Then I could see the local preview in my web browser.
Possible Solution
Ideally a new user would have the .env file created and populated - and the guide seems to say it's going to do so. So I was surprised that I had to do the extra manual steps. Is that expected?
Steps to Reproduce
Run contentful guide and create a new account, then paste in the CMA token created. Go through the rest of the steps to set up a "Gatsby Starter Blog" and new Space.
(One error I did see was this rate limit, but it seems to have resolved quickly:
The following 0 errors and 1 warnings occurred:
22:24:37 - Rate limit error occurred. Waiting for 1568 ms before retrying...
The import was successful.
This is the resulting error at the end of contentful guide that made me think I should be able to run npm run dev without further file creation:
Almost done! Your Gatsby Starter Blog has been set up on your local machine. It will now be started by running: npm run dev
A browser will open showing your new Gatsby Starter Blog. Feel free to make changes to the code
and see them appear immediately.
You may exit development mode by pressing the Q or CTRL+C
? Run Gatsby Starter Blog locally in development mode now? Yes
> [email protected] dev /Users/annegentle/src/gatsby-contentful
> gatsby develop
╔════════════════════════════════════════════════════════════════════════╗
║ ║
║ Gatsby collects anonymous usage analytics ║
║ to help improve Gatsby for all users. ║
║ ║
║ If you'd like to opt-out, you can use `gatsby telemetry --disable` ║
║ To learn more, checkout https://gatsby.dev/telemetry ║
║ ║
╚════════════════════════════════════════════════════════════════════════╝
ERROR #10123 CONFIG
We encountered an error while trying to load your site's gatsby-config. Please fix the error and try again.
Error: Contentful spaceId and the access token need to be provided.
Context
I wanted to get started quickly and contentful guide looked like the right way to start.
Environment
- Language Version: v14.15.5
- Package Manager Version: 6.14.11
- Browser Version: N/A
-
Operating System:
Darwin 2019-MacbookPro.local 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64 - Package Version:
npm list contentful
[email protected] /Users/annegentle/src/gatsby-contentful
└─┬ [email protected]
└── [email protected]
Thanks for letting me know if the dotenv file should have been created for me.