Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config server #22

Open
dcjayasuriya2020 opened this issue Jan 7, 2021 · 5 comments
Open

config server #22

dcjayasuriya2020 opened this issue Jan 7, 2021 · 5 comments

Comments

@dcjayasuriya2020
Copy link

2 things:
1.
when we have to export config file to index.js, code in config should mention correct module/
in this lecture the export "environmentToExport" does not directly noticed.. as if we use "config" inside index from config.js file, then within the config file there shuold be at least the word "config"
so to export I did: export const config = environmentToExport;

  1. on terminal (my OS is windows), NODE_ENV=staging (or production) does not detect at all... it gives only
    `NODE_ENV=staging node index.js NODE_ENV=staging : The term 'NODE_ENV=staging' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + NODE_ENV=staging node index.js + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (NODE_ENV=staging:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

I tried: $setNODE_ENV="production"` not working???

can someone fix it?

@spriggs81
Copy link

Can you provide the config file? And the require line in the index.js?

@dcjayasuriya2020
Copy link
Author

dcjayasuriya2020 commented Jan 7, 2021 via email

@avinash-n992
Copy link

avinash-n992 commented Jun 14, 2021

Hi,

I am still facing the issue.
I tried the following command as I have Windows.

SET NODE_ENV=staging ; node index.js

But it still sets the default port and environment, even if I change in the CLI

Adding a screenshot as well.
image

@Danbaba1
Copy link

var environment = {};

environment.staging = {
    'port' : '3000',
    'envName' : 'staging'
};

environment.production = {
    'port' : '5000',
    'envName' : 'production'
};

var currentEnvironment = typeof(process.env.NODE_ENV)  == 'string' ? process.env.NODE_ENV.toLowerCase() : '';

var environmentToExport = typeof(environment[currentEnvironment]) == 'object' ? environment[currentEnvironment] : environment.staging;

module.exports = environmentToExport;

@Danbaba1
Copy link

const config = require('./config');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants