Maksim Rubanau
Maksim Rubanau

Reputation: 86

Node.js - How to get custom environment variable with config?

I am running [email protected] 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 fine.

.\config\custom-environment-variables.json

{
  "jwtPrivateKey": "sс_jwtPrivateKey"
}

.\config\default.json

{
  "jwtPrivateKey": "default"
}

console.log(config.get('jwtPrivateKey')) always prints default

I made this in cmd: SET sс_jwtPrivateKey=12345678

I tried new version of config, the same situation.

It prints nothing when I set the key property in config/default to an empty string. How can I resolve this?

How to get the value of sc_jwtPrivateKey?

THANK YOU!

Upvotes: 2

Views: 1744

Answers (3)

Darshan17
Darshan17

Reputation: 111

Use an External Terminal not the Integrated Terminal

Upvotes: 1

tareq aziz
tareq aziz

Reputation: 777

Try this following command in windows powershell to set the value of sc_jwtPrivateKey

$env:sс_jwtPrivateKey="12345678"

Or try this following in cmd

set sс_jwtPrivateKey=12345678

Upvotes: 1

Maksim Rubanau
Maksim Rubanau

Reputation: 86

I solved the problem as follows: Instead SET sс_jwtPrivateKey=12345678, I used SETX sс_jwtPrivateKey 12345678.

Upvotes: 1

Related Questions