Comments (10)
I'm also facing the same issue when using ES modules import
in JS and TS as well when using config.get("dar-api-port")
. Following is the error that I receive in the console.
D:\TechACOS\dar-app\dar-api\node_modules\config\lib\config.js:179
throw new Error('Configuration property "' + property + '" is not defined');
^
Error: Configuration property "dar-api-port" is not defined
And when I used config.util.getEnv("dar-api-port")
, it returned undefined.
from node-config.
Please contribute a failing test for the test suite that demonstrates the bug. This feature is working fine for me. The test will help illustrate what's different in your case.
from node-config.
Moved it to #725
I have the same issue in my node app. I am not sure what test suite to use etc, apologize for my ignorance. But here is what I have. I have default.json, development.json and production.json. I have an environment variable 'app_password' with password. I have custom-environment-variables.json with the following:
`
{
"mail":{
"password":"app_password"
}
}
`
In my index.js I have
`
console.log('Mail Password: ' + config.get('mail.password'));
`
I get the following error
Error: Configuration property "mail.password" is not defined
at Config.get (C:\Users\devtr\Desktop\Vidly\node_modules\config\lib\config.js:179:11)
etc etc.
I hope this helps and can get it resolved. Thank you
from node-config.
@devtrix how are you importing the config module in your code?
import config from "config"
or
const config = require("config")
from node-config.
@talhameer The second, const config = require("config")
from node-config.
@markstos When I define a variable that is set into 'custom-environment-variables.json' but not set into development.json, I got error that is not found:
└───────────────────────────────────┘
Config { name: 'My app - development', jwtPrivateKey: '' }
/..../GitHub/nodejs-starter/startup/config.js:6
throw new Error("FATAL ERROR: jwt key not found!");
Here is my config.js file:
const config = require("config");
module.exports = function() {
if (!config.get("jwtPrivateKey")) {
throw new Error("FATAL ERROR: jwt key not found!");
return process.exit(1);
}
}
This is my development.json:
{
"name": "My app - development",
"jwtPrivateKey": ""
}
And into custom-environment-variables.json
file, I have just this field jwtPrivateKey
.
There are other json files into config folder, production and default that are same as development but with different name.
from node-config.
I'm getting this error too.
from node-config.
I am encountering the same error when I run the server in VS Code's integrated terminal, but when I run it in an external terminal, it works without any issues.
from node-config.
Everyone, you need to confirm that the environment variable you are trying to read is actually passed to node-config
.
In the first line in your script, use something like console.log("DEBUG", process.env.YOUR_VAR_NAME)
. If you don't get any output, the variable is not set by your environment and there's nothing node-config
can do about that.
I'm closing this thread, because it's more of a support thread and not a bug report-- If there was an actual bug, you could contribute a failing test for the test suite to reproduce it as something that's definitely a node-config problem.
from node-config.
The issue is with VS Code Terminal. It not picking the file or object.
Try external node terminal. It will work.
from node-config.
Related Issues (20)
- custom-environment-variables.json says variable is not defined. HOT 1
- Feature Request: First class Kubernetes secret files support HOT 3
- [BUG] Cypress component testing fails with error `<CONFIG_VARIABLE> is not defined`
- Deal With Async Properties in DeferConfig HOT 1
- [BUG] Documentation is missing HOT 4
- [BUG] custom-environment-variables file does not support cjs extension HOT 2
- [BUG] Extra quotes on config file broke app HOT 5
- Cannot use defer with esbuild (fix: export defer from config) HOT 1
- Unable to use
- [BUG] Configuration files with different extensions and APP_INSTANCE not loaded in the right order HOT 2
- [BUG] Javascript getters calling during config initialization
- [BUG] Empty key in YAML sets value to null HOT 2
- [BUG] Environment variable substitution fails silently if "__format" parser is not supported HOT 1
- Project breaks after updating ts version (using .cjs config files)
- v3.3.10 is a breaking change for webpack, which does not install json5 dep HOT 18
- Disable some "defaults", like local.{ext} loading HOT 3
- [BUG] node-config package.json has not all the parsers available installed as production dependencies HOT 6
- [BUG] YAML binary type is mangled
- [BUG] Encoungering an unexpected ENOTDIR while trying to open non-existing runtime.json
- [BUG] DeprecationWarnings in node v22 DEP0055 DEP0047 DEP0044
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-config.