Giter Club home page Giter Club logo

Comments (10)

talhameer avatar talhameer commented on June 2, 2024

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.

markstos avatar markstos commented on June 2, 2024

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.

devtrix avatar devtrix commented on June 2, 2024

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.

talhameer avatar talhameer commented on June 2, 2024

@devtrix how are you importing the config module in your code?

import config from "config"
or
const config = require("config")

from node-config.

devtrix avatar devtrix commented on June 2, 2024

@talhameer The second, const config = require("config")

from node-config.

MahmonirB avatar MahmonirB commented on June 2, 2024

@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.

reddythedev avatar reddythedev commented on June 2, 2024

I'm getting this error too.

from node-config.

elqessouartariq avatar elqessouartariq commented on June 2, 2024

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.

markstos avatar markstos commented on June 2, 2024

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.

seAfnan avatar seAfnan commented on June 2, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.