Questions tagged [node-config]

Use this tag if you have a question specifically to https://www.npmjs.com/package/config. For other nodejs configuration question, you are probably better off using the nodejs tag.

Node-config is a popular package for managing configuration files for nodejs applications.

60 questions
28
votes
9 answers

How to use node-config in typescript?

After installing node-config and @types/config: yarn add config yarn add --dev @types/config And adding config as described in lorenwest/node-config: // default.ts export default { server: { port: 4000, }, logLevel: 'error', }; When I am…
Deepak
  • 2,487
  • 3
  • 21
  • 27
18
votes
4 answers

WARNING: NODE_ENV value of 'test ' did not match any deployment config file names

Receiving this warning on running a node.js app despite all testing suggesting everything fine. I've included the below code in my app to fault find: console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV')); console.log('NODE_CONFIG_DIR: ' +…
BlueWolf
  • 185
  • 1
  • 1
  • 9
12
votes
6 answers

NodeJS - config cannot not load custom environment variables

I am running config@1.30.0 and I am attempting to get settings from the environment variables using .\config\custom-environment-variables.json does not work. However, it reads from the .\config\default.json just…
djangbahevans
  • 153
  • 1
  • 2
  • 6
11
votes
4 answers

How do I override config values at runtime with node-config?

I'd like to override some values at test-time, specifically setting my retries for an http service to 1 (immediate failure, no retries). Our project uses node-config. According to the docs I can override with NODE_CONFIG env variable: node myapp.js…
jcollum
  • 43,623
  • 55
  • 191
  • 321
9
votes
3 answers

Proper way to parse environment variables

I am using node-config in basically all my projects and most of the time I come across the problem of parsing booleans and numbers which are set as environment variables. E.g. default.js module.exports = { myNumber = 10, myBool =…
nflaig
  • 673
  • 1
  • 8
  • 15
7
votes
4 answers

Emit skipped when parsing config typescript files

I have a problem with the node-config library while using typescript. My config folder is as follows: However after I run tsc and try to start my app from it's entry point (app.js) I get the following error: Error: Cannot parse config file:…
Michael Ostrovsky
  • 629
  • 1
  • 7
  • 21
6
votes
1 answer

Load ENV vars with dotenv before node-config

I want to load environment variables into the general config of my Express app. Locally I work with a .env file, but when deploying, I'll inject the env vars into the docker container. So, I've got a default.json with some hard-coded config values.…
Milkncookiez
  • 6,817
  • 10
  • 57
  • 96
5
votes
1 answer

Mock specific config value in jest

I have the following default/config.js file /* eslint-disable @typescript-eslint/no-var-requires */ require('dotenv').config({ path: require('find-config')('.env'), }); module.exports = { cronInterval: process.env.CRON_INTERVAL, queueName:…
AngularDebutant
  • 1,436
  • 5
  • 19
  • 41
5
votes
3 answers

Node-config custom-environment-variables not overridding default.json during test

Node-config's custom-environment-variables.json doesn't seem to be overriding values in default.json when NODE_ENV is set to 'test.' Here's an extremely simple config: config/default.json: { "jwtPrivateKey":…
J23
  • 3,061
  • 6
  • 41
  • 52
5
votes
3 answers

nodejs sequelize/cli how to use with node-config

First off it's my first time with Sequelize so be patient. I'd like to use https://github.com/sequelize/cli along with https://github.com/lorenwest/node-config I want sequelize to be able to "compose" it's configuration from multiple source files,…
Whisher
  • 31,320
  • 32
  • 120
  • 201
3
votes
1 answer

Global node-config variable undefined when testing with Jest

I am implementing Option 2 from the node-config docs. This runs fine, and my global config variable is defined when running outside of a test environment. However, when I run this with vue-cli and Jest unit testing (e.g. vue-cli-service test:unit),…
writofmandamus
  • 1,151
  • 1
  • 23
  • 40
3
votes
3 answers

Node-config won't use variables from custom-environment-variables.json in Heroku

I'm using the node-config module for mongo connection strings and jwt keys. For example: if(!config.get('jwtPrivateKey')){ throw new Error('FATAL ERROR: jwtPrivateKey is not defined'); My custom-environment-variables.json file looks like: { …
NickW
  • 1,207
  • 1
  • 12
  • 52
3
votes
3 answers

TypeError: Key must be a buffer when sending an email with aws-sdk in node.js

I'm trying to set up an emailing system with nodemailer that's agnostic of the transport type it uses. Here's how I'm trying to send the email: const config = require('config') const mailerConfig = config.get('mailer') const transporter =…
Sebastian
  • 250
  • 1
  • 13
2
votes
2 answers

mock node config with jest

I introduce myself currently for the first time in jest and nodejs. I am facing the problem that I have to mock two different values from the nodejs config. jest.mock('config') mockConfigTtl =…
nano_nano
  • 12,351
  • 8
  • 55
  • 83
2
votes
1 answer

Node-config custom-environment-variables not Picking Docker environment Variables

Working on Windows OS. My node app using node-config isn't using docker environment variables. It's always using the default config. I am using node-config custom environment variables as described here:…
Sumatan
  • 106
  • 1
  • 7
1
2 3 4