requiring ('dotenv') inside of gatsby-config.js breaks resulting in webpack error #35620
Replies: 6 comments 3 replies
-
@luiscmartinez did you manage to find a solution? I'm trying to update my gatsby project and I am stuck with that dotenv error. |
Beta Was this translation helpful? Give feedback.
-
Try install |
Beta Was this translation helpful? Give feedback.
-
I'm having this issue too - any resolutions yet? |
Beta Was this translation helpful? Give feedback.
-
Hi, this issue still presists. Is there any news about that? The offical documentation (https://www.gatsbyjs.com/docs/how-to/local-development/environment-variables/) still is telling us to require("dotenv"), whichs prodcues the fs error. |
Beta Was this translation helpful? Give feedback.
-
Hi, also stuck with this error. Any updates? Installing dotenv is not fixing this for me. Still getting webpack compile errors when importing dotenv in gatsby-config. |
Beta Was this translation helpful? Give feedback.
-
Same thing here. I'm unable to load a local config: import type { GatsbyConfig } from "gatsby";
import dotenv from "dotenv";
dotenv.config({
path: `.env.${process.env.NODE_ENV}`
}); Running with gatsby 5.13.2. |
Beta Was this translation helpful? Give feedback.
-
Preliminary Checks
Description
Project builds successfully but as soon as I require dotenv inside of the gatsby-config.js file, I get a webpack error
Reproduction Link
https://github.com/luiscmartinez/gatsby-portfolio-1
Steps to Reproduce
npm i
npm run dev
(runs gatsby develop)require('dotenv').config()
to the top of thegatsby-config.js
file...
After this you should get the webpack error
Expected Result
Actual Result
Environment
Config Flags
No response
Beta Was this translation helpful? Give feedback.
All reactions