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
Linux vmi700946 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
module.exports = () => {
let envConfig = require("dotenv").config().parsed || {};
let localConfig = require("../config");
let config = {
...localConfig,
...envConfig
}
// Check for required keys
["ENV", "ENVS"].forEach(k => {
if (!config[k]) throw new Error(`${k} is missing from config and it is required.`)
});
// Check if enviroment is a valid one
if (!config.ENVS.includes(config.ENV))
throw new Error(`${config.ENV} is not an allowed enviroment.\nEnv must be one of these: ${config.ENVS.join(", ")}`)
global.config = config;
}
On "Check for required keys" part, when the array is set straight on forEach, it will throw Cannot access 'config' before initialization in the loop.
If the array is set as a variable like this, it runs completely fine.
let arr = ["ENV", "ENVS"]
arr.forEach(k => {
if (!config[k]) throw new Error(`${k} is missing from config and it is required.`)
});
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered:
Version
v16.18.1
Platform
Linux vmi700946 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
On "Check for required keys" part, when the array is set straight on forEach, it will throw
Cannot access 'config' before initialization
in the loop.If the array is set as a variable like this, it runs completely fine.
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
No response
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: