You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, with this config setup, if I run npm start, everything works fine. NODE_ENV gets set to development, the relevant dotenv file gets loaded, all is good.
However, if I run npm run build, no joy. A quick check of console.log(process.env.NODE_ENV); inside docusaurus.config.js reveals that in this context, NODE_ENV is undefined.
Would anyone be able to assist? Am I missing something here?
Further info.
I made the following second attempt to check something...
I added a fallback value for that url config setting in case the dotenv config value can't be evaluated.
and I noticed that docusaurus.config.js appears to load twice, resulting in the following console output...
$ npm run build
> docs-website@0.0.0 build
> docusaurus build
process.env.NODE_ENV is: undefined
[INFO] [en] Creating an optimized production build...
process.env.NODE_ENV is: production
✔ Client
✔ Server
Compiled successfully in 18.64s
✔ Client
● Server █████████████████████████ cache (99%) shutdown IdleFileCachePlugin
stored
[SUCCESS] Generated static files in "build".
[INFO] Use `npm run serve` command to test your build locally.
So it looks like the first time through, process.env.NODE_ENV isn't set, which result in an error in node_modules\@docusaurus\core\lib\server\configValidation.js i.e. [ERROR] Error: "url" is required if you only rely on dotenv config alone, without the fallback as per my second attempt
Do you think this is a bug worth reporting?
The text was updated successfully, but these errors were encountered:
Josh-Cena
added
the
bug
An error in the Docusaurus core causing instability or issues with its execution
label
Jan 30, 2023
Discussed in #8549
Originally posted by miller-productions January 13, 2023
Hi folks,
I'm trying out using dotenv to dynamically set different values for
url
in the filedocusaurus.config.js
For example...
In
docusaurus.config.js
, I have the following relevant lines...Then, I have separate dotenv files as such
and
Now, with this config setup, if I run
npm start
, everything works fine. NODE_ENV gets set todevelopment
, the relevant dotenv file gets loaded, all is good.However, if I run
npm run build
, no joy. A quick check ofconsole.log(process.env.NODE_ENV);
insidedocusaurus.config.js
reveals that in this context, NODE_ENV isundefined
.Would anyone be able to assist? Am I missing something here?
Further info.
I made the following second attempt to check something...
I added a fallback value for that
url
config setting in case the dotenv config value can't be evaluated.and I noticed that
docusaurus.config.js
appears to load twice, resulting in the following console output...So it looks like the first time through,
process.env.NODE_ENV
isn't set, which result in an error innode_modules\@docusaurus\core\lib\server\configValidation.js
i.e.[ERROR] Error: "url" is required
if you only rely on dotenv config alone, without the fallback as per my second attemptDo you think this is a bug worth reporting?
The text was updated successfully, but these errors were encountered: