Setup app production and developent mode in node.js











up vote
0
down vote

favorite












In my node app, I want to set production and development in my config.js file.



For that I have all most set all thing but I'm still mssing some thing.



I want to get config data like database credential from config fiel based on my development mode. If I upload on live then app will use live cred. On other hand if I used local then it should be use local cred.



module.exports = function () {
console.log("Process env is ::: ", process.env.NODE_ENV);
if (process.env.NODE_ENV == 'production') {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
} else {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
}
};


Thanks in advanced. I have taken ref from this answer










share|improve this question




















  • 1




    What’s your question?
    – Mazki516
    Nov 22 at 16:36










  • @Mazki516 I have update my question.
    – khushboo
    Nov 22 at 16:38






  • 1




    @khushboo still I cannot filter out a specific question from this post
    – Kristianmitk
    Nov 22 at 16:41










  • @Kristianmitk I want to set dynamic config values in app. For that I have set this code. So by just one value changed, whole app will use live config data.
    – khushboo
    Nov 22 at 16:44










  • I understand that, but this still does not reveal a question. In other words: whats the reason for this post?
    – Kristianmitk
    Nov 22 at 16:58















up vote
0
down vote

favorite












In my node app, I want to set production and development in my config.js file.



For that I have all most set all thing but I'm still mssing some thing.



I want to get config data like database credential from config fiel based on my development mode. If I upload on live then app will use live cred. On other hand if I used local then it should be use local cred.



module.exports = function () {
console.log("Process env is ::: ", process.env.NODE_ENV);
if (process.env.NODE_ENV == 'production') {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
} else {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
}
};


Thanks in advanced. I have taken ref from this answer










share|improve this question




















  • 1




    What’s your question?
    – Mazki516
    Nov 22 at 16:36










  • @Mazki516 I have update my question.
    – khushboo
    Nov 22 at 16:38






  • 1




    @khushboo still I cannot filter out a specific question from this post
    – Kristianmitk
    Nov 22 at 16:41










  • @Kristianmitk I want to set dynamic config values in app. For that I have set this code. So by just one value changed, whole app will use live config data.
    – khushboo
    Nov 22 at 16:44










  • I understand that, but this still does not reveal a question. In other words: whats the reason for this post?
    – Kristianmitk
    Nov 22 at 16:58













up vote
0
down vote

favorite









up vote
0
down vote

favorite











In my node app, I want to set production and development in my config.js file.



For that I have all most set all thing but I'm still mssing some thing.



I want to get config data like database credential from config fiel based on my development mode. If I upload on live then app will use live cred. On other hand if I used local then it should be use local cred.



module.exports = function () {
console.log("Process env is ::: ", process.env.NODE_ENV);
if (process.env.NODE_ENV == 'production') {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
} else {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
}
};


Thanks in advanced. I have taken ref from this answer










share|improve this question















In my node app, I want to set production and development in my config.js file.



For that I have all most set all thing but I'm still mssing some thing.



I want to get config data like database credential from config fiel based on my development mode. If I upload on live then app will use live cred. On other hand if I used local then it should be use local cred.



module.exports = function () {
console.log("Process env is ::: ", process.env.NODE_ENV);
if (process.env.NODE_ENV == 'production') {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
} else {
return {
db : {
host:'localhost',
batabase:'dbname',
username:'',
password:''
}
}
}
};


Thanks in advanced. I have taken ref from this answer







node.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 16:43

























asked Nov 22 at 16:34









khushboo

6711




6711








  • 1




    What’s your question?
    – Mazki516
    Nov 22 at 16:36










  • @Mazki516 I have update my question.
    – khushboo
    Nov 22 at 16:38






  • 1




    @khushboo still I cannot filter out a specific question from this post
    – Kristianmitk
    Nov 22 at 16:41










  • @Kristianmitk I want to set dynamic config values in app. For that I have set this code. So by just one value changed, whole app will use live config data.
    – khushboo
    Nov 22 at 16:44










  • I understand that, but this still does not reveal a question. In other words: whats the reason for this post?
    – Kristianmitk
    Nov 22 at 16:58














  • 1




    What’s your question?
    – Mazki516
    Nov 22 at 16:36










  • @Mazki516 I have update my question.
    – khushboo
    Nov 22 at 16:38






  • 1




    @khushboo still I cannot filter out a specific question from this post
    – Kristianmitk
    Nov 22 at 16:41










  • @Kristianmitk I want to set dynamic config values in app. For that I have set this code. So by just one value changed, whole app will use live config data.
    – khushboo
    Nov 22 at 16:44










  • I understand that, but this still does not reveal a question. In other words: whats the reason for this post?
    – Kristianmitk
    Nov 22 at 16:58








1




1




What’s your question?
– Mazki516
Nov 22 at 16:36




What’s your question?
– Mazki516
Nov 22 at 16:36












@Mazki516 I have update my question.
– khushboo
Nov 22 at 16:38




@Mazki516 I have update my question.
– khushboo
Nov 22 at 16:38




1




1




@khushboo still I cannot filter out a specific question from this post
– Kristianmitk
Nov 22 at 16:41




@khushboo still I cannot filter out a specific question from this post
– Kristianmitk
Nov 22 at 16:41












@Kristianmitk I want to set dynamic config values in app. For that I have set this code. So by just one value changed, whole app will use live config data.
– khushboo
Nov 22 at 16:44




@Kristianmitk I want to set dynamic config values in app. For that I have set this code. So by just one value changed, whole app will use live config data.
– khushboo
Nov 22 at 16:44












I understand that, but this still does not reveal a question. In other words: whats the reason for this post?
– Kristianmitk
Nov 22 at 16:58




I understand that, but this still does not reveal a question. In other words: whats the reason for this post?
– Kristianmitk
Nov 22 at 16:58












3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










Just try this way.



module.exports = (function () {
process.env.NODE_ENV='development';
if(process.env.NODE_ENV === 'production'){
// Config data of Live
}else{
//Config data of Local
}
})()


This works for me. :)






share|improve this answer




























    up vote
    0
    down vote













    process.env refers to the Environment Variables exists at the time you start you nodejs app . (it's part of the os)



    When you deploy to cloud , usually it's handled for you already (process.env.NODE_ENV = production) .
    Some cloud providers even give you the option to control it via a GUI .



    But for local environment , you can use .dotenv package . (https://github.com/motdotla/dotenv)



    With this package you create a .env file at the top of your project ,



    and just write down NODE_ENV = local/staging/production



    Please note that you can always run in shell:



    export NODE_ENV=production


    (WATCH FOR WHITESPACES !)
    before you start you nodejs app which will also give you the effect
    of controlling process.env



    Using the config files in other files, just by requiring it .



    const config = require('path/to/config.js');


    then config.data.host will be changed depend on the NODE_ENV






    share|improve this answer























    • I just want to use config data in otehr file as in my comment. config.data.database
      – khushboo
      Nov 22 at 17:07










    • i've updated the answer
      – Mazki516
      Nov 22 at 17:12


















    up vote
    0
    down vote













    You can use nconf npm



    let myconfig.js



    var nconf = module.exports = require('nconf');
    var path = require('path');

    nconf
    // 1. Command-line arguments
    .argv()
    // 2. Environment variables
    .env([
    'MYSQL_PASSWORD',
    'MYSQL_HOST',
    'PORT'
    ])
    // 3. Config file
    .file({file: path.join(__dirname, 'config.json')})
    // 4. Defaults
    .defaults({

    //Development DB config details
    MYSQL_USER: 'XXXX',
    MYSQL_PASSWORD: 'XXXX',
    MYSQL_HOST : 'localhost',
    PORT:8081

    });


    app.js



    const myconfig = require('./configurations/myconfig');
    //IT ll fetch PORT ffrom process.env.PORT else not declare ll use default which is 8081 defined in myconfig.js

    const PORT=myconfig.get('PORT')//8081

    module.exports = function () {
    console.log("Process env is ::: ", process.env.NODE_ENV);
    if (process.env.NODE_ENV == 'production') {
    return {
    db : {
    host:process.env.HOST,
    database:process.env.DBNAME,
    username:process.env.username,
    password:process.env.password
    }
    }
    } else {
    return {
    db : {
    host:'localhost',
    batabase:'dbname',
    username:'',
    password:''
    }
    }
    }
    };


    You have to set your HOST/DBNAME/PASSWORD variables in production env[cloud heroku/aws/gcp]






    share|improve this answer























    • Thanks for reply. I want to do simple, and I want to just find issue in my code. I don't want to install any other modules. Can you please help to improve my code. :)
      – khushboo
      Nov 22 at 17:27










    • i have edited,if it is helpful@khushboo
      – BittuS
      Nov 22 at 17:36










    • I got TypeError: Cannot read property 'host' of undefined error
      – khushboo
      Nov 22 at 17:44










    • these variables you ll get in production enviornment after setting it,for local HOST=localhost PASSWORD=foobar node app.js while starting node application It ll set process.env.HOST=localhost
      – BittuS
      Nov 22 at 17:53













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435103%2fsetup-app-production-and-developent-mode-in-node-js%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Just try this way.



    module.exports = (function () {
    process.env.NODE_ENV='development';
    if(process.env.NODE_ENV === 'production'){
    // Config data of Live
    }else{
    //Config data of Local
    }
    })()


    This works for me. :)






    share|improve this answer

























      up vote
      1
      down vote



      accepted










      Just try this way.



      module.exports = (function () {
      process.env.NODE_ENV='development';
      if(process.env.NODE_ENV === 'production'){
      // Config data of Live
      }else{
      //Config data of Local
      }
      })()


      This works for me. :)






      share|improve this answer























        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Just try this way.



        module.exports = (function () {
        process.env.NODE_ENV='development';
        if(process.env.NODE_ENV === 'production'){
        // Config data of Live
        }else{
        //Config data of Local
        }
        })()


        This works for me. :)






        share|improve this answer












        Just try this way.



        module.exports = (function () {
        process.env.NODE_ENV='development';
        if(process.env.NODE_ENV === 'production'){
        // Config data of Live
        }else{
        //Config data of Local
        }
        })()


        This works for me. :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 at 4:38









        Sachin Shah

        1,095414




        1,095414
























            up vote
            0
            down vote













            process.env refers to the Environment Variables exists at the time you start you nodejs app . (it's part of the os)



            When you deploy to cloud , usually it's handled for you already (process.env.NODE_ENV = production) .
            Some cloud providers even give you the option to control it via a GUI .



            But for local environment , you can use .dotenv package . (https://github.com/motdotla/dotenv)



            With this package you create a .env file at the top of your project ,



            and just write down NODE_ENV = local/staging/production



            Please note that you can always run in shell:



            export NODE_ENV=production


            (WATCH FOR WHITESPACES !)
            before you start you nodejs app which will also give you the effect
            of controlling process.env



            Using the config files in other files, just by requiring it .



            const config = require('path/to/config.js');


            then config.data.host will be changed depend on the NODE_ENV






            share|improve this answer























            • I just want to use config data in otehr file as in my comment. config.data.database
              – khushboo
              Nov 22 at 17:07










            • i've updated the answer
              – Mazki516
              Nov 22 at 17:12















            up vote
            0
            down vote













            process.env refers to the Environment Variables exists at the time you start you nodejs app . (it's part of the os)



            When you deploy to cloud , usually it's handled for you already (process.env.NODE_ENV = production) .
            Some cloud providers even give you the option to control it via a GUI .



            But for local environment , you can use .dotenv package . (https://github.com/motdotla/dotenv)



            With this package you create a .env file at the top of your project ,



            and just write down NODE_ENV = local/staging/production



            Please note that you can always run in shell:



            export NODE_ENV=production


            (WATCH FOR WHITESPACES !)
            before you start you nodejs app which will also give you the effect
            of controlling process.env



            Using the config files in other files, just by requiring it .



            const config = require('path/to/config.js');


            then config.data.host will be changed depend on the NODE_ENV






            share|improve this answer























            • I just want to use config data in otehr file as in my comment. config.data.database
              – khushboo
              Nov 22 at 17:07










            • i've updated the answer
              – Mazki516
              Nov 22 at 17:12













            up vote
            0
            down vote










            up vote
            0
            down vote









            process.env refers to the Environment Variables exists at the time you start you nodejs app . (it's part of the os)



            When you deploy to cloud , usually it's handled for you already (process.env.NODE_ENV = production) .
            Some cloud providers even give you the option to control it via a GUI .



            But for local environment , you can use .dotenv package . (https://github.com/motdotla/dotenv)



            With this package you create a .env file at the top of your project ,



            and just write down NODE_ENV = local/staging/production



            Please note that you can always run in shell:



            export NODE_ENV=production


            (WATCH FOR WHITESPACES !)
            before you start you nodejs app which will also give you the effect
            of controlling process.env



            Using the config files in other files, just by requiring it .



            const config = require('path/to/config.js');


            then config.data.host will be changed depend on the NODE_ENV






            share|improve this answer














            process.env refers to the Environment Variables exists at the time you start you nodejs app . (it's part of the os)



            When you deploy to cloud , usually it's handled for you already (process.env.NODE_ENV = production) .
            Some cloud providers even give you the option to control it via a GUI .



            But for local environment , you can use .dotenv package . (https://github.com/motdotla/dotenv)



            With this package you create a .env file at the top of your project ,



            and just write down NODE_ENV = local/staging/production



            Please note that you can always run in shell:



            export NODE_ENV=production


            (WATCH FOR WHITESPACES !)
            before you start you nodejs app which will also give you the effect
            of controlling process.env



            Using the config files in other files, just by requiring it .



            const config = require('path/to/config.js');


            then config.data.host will be changed depend on the NODE_ENV







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 22 at 17:11

























            answered Nov 22 at 17:02









            Mazki516

            5631416




            5631416












            • I just want to use config data in otehr file as in my comment. config.data.database
              – khushboo
              Nov 22 at 17:07










            • i've updated the answer
              – Mazki516
              Nov 22 at 17:12


















            • I just want to use config data in otehr file as in my comment. config.data.database
              – khushboo
              Nov 22 at 17:07










            • i've updated the answer
              – Mazki516
              Nov 22 at 17:12
















            I just want to use config data in otehr file as in my comment. config.data.database
            – khushboo
            Nov 22 at 17:07




            I just want to use config data in otehr file as in my comment. config.data.database
            – khushboo
            Nov 22 at 17:07












            i've updated the answer
            – Mazki516
            Nov 22 at 17:12




            i've updated the answer
            – Mazki516
            Nov 22 at 17:12










            up vote
            0
            down vote













            You can use nconf npm



            let myconfig.js



            var nconf = module.exports = require('nconf');
            var path = require('path');

            nconf
            // 1. Command-line arguments
            .argv()
            // 2. Environment variables
            .env([
            'MYSQL_PASSWORD',
            'MYSQL_HOST',
            'PORT'
            ])
            // 3. Config file
            .file({file: path.join(__dirname, 'config.json')})
            // 4. Defaults
            .defaults({

            //Development DB config details
            MYSQL_USER: 'XXXX',
            MYSQL_PASSWORD: 'XXXX',
            MYSQL_HOST : 'localhost',
            PORT:8081

            });


            app.js



            const myconfig = require('./configurations/myconfig');
            //IT ll fetch PORT ffrom process.env.PORT else not declare ll use default which is 8081 defined in myconfig.js

            const PORT=myconfig.get('PORT')//8081

            module.exports = function () {
            console.log("Process env is ::: ", process.env.NODE_ENV);
            if (process.env.NODE_ENV == 'production') {
            return {
            db : {
            host:process.env.HOST,
            database:process.env.DBNAME,
            username:process.env.username,
            password:process.env.password
            }
            }
            } else {
            return {
            db : {
            host:'localhost',
            batabase:'dbname',
            username:'',
            password:''
            }
            }
            }
            };


            You have to set your HOST/DBNAME/PASSWORD variables in production env[cloud heroku/aws/gcp]






            share|improve this answer























            • Thanks for reply. I want to do simple, and I want to just find issue in my code. I don't want to install any other modules. Can you please help to improve my code. :)
              – khushboo
              Nov 22 at 17:27










            • i have edited,if it is helpful@khushboo
              – BittuS
              Nov 22 at 17:36










            • I got TypeError: Cannot read property 'host' of undefined error
              – khushboo
              Nov 22 at 17:44










            • these variables you ll get in production enviornment after setting it,for local HOST=localhost PASSWORD=foobar node app.js while starting node application It ll set process.env.HOST=localhost
              – BittuS
              Nov 22 at 17:53

















            up vote
            0
            down vote













            You can use nconf npm



            let myconfig.js



            var nconf = module.exports = require('nconf');
            var path = require('path');

            nconf
            // 1. Command-line arguments
            .argv()
            // 2. Environment variables
            .env([
            'MYSQL_PASSWORD',
            'MYSQL_HOST',
            'PORT'
            ])
            // 3. Config file
            .file({file: path.join(__dirname, 'config.json')})
            // 4. Defaults
            .defaults({

            //Development DB config details
            MYSQL_USER: 'XXXX',
            MYSQL_PASSWORD: 'XXXX',
            MYSQL_HOST : 'localhost',
            PORT:8081

            });


            app.js



            const myconfig = require('./configurations/myconfig');
            //IT ll fetch PORT ffrom process.env.PORT else not declare ll use default which is 8081 defined in myconfig.js

            const PORT=myconfig.get('PORT')//8081

            module.exports = function () {
            console.log("Process env is ::: ", process.env.NODE_ENV);
            if (process.env.NODE_ENV == 'production') {
            return {
            db : {
            host:process.env.HOST,
            database:process.env.DBNAME,
            username:process.env.username,
            password:process.env.password
            }
            }
            } else {
            return {
            db : {
            host:'localhost',
            batabase:'dbname',
            username:'',
            password:''
            }
            }
            }
            };


            You have to set your HOST/DBNAME/PASSWORD variables in production env[cloud heroku/aws/gcp]






            share|improve this answer























            • Thanks for reply. I want to do simple, and I want to just find issue in my code. I don't want to install any other modules. Can you please help to improve my code. :)
              – khushboo
              Nov 22 at 17:27










            • i have edited,if it is helpful@khushboo
              – BittuS
              Nov 22 at 17:36










            • I got TypeError: Cannot read property 'host' of undefined error
              – khushboo
              Nov 22 at 17:44










            • these variables you ll get in production enviornment after setting it,for local HOST=localhost PASSWORD=foobar node app.js while starting node application It ll set process.env.HOST=localhost
              – BittuS
              Nov 22 at 17:53















            up vote
            0
            down vote










            up vote
            0
            down vote









            You can use nconf npm



            let myconfig.js



            var nconf = module.exports = require('nconf');
            var path = require('path');

            nconf
            // 1. Command-line arguments
            .argv()
            // 2. Environment variables
            .env([
            'MYSQL_PASSWORD',
            'MYSQL_HOST',
            'PORT'
            ])
            // 3. Config file
            .file({file: path.join(__dirname, 'config.json')})
            // 4. Defaults
            .defaults({

            //Development DB config details
            MYSQL_USER: 'XXXX',
            MYSQL_PASSWORD: 'XXXX',
            MYSQL_HOST : 'localhost',
            PORT:8081

            });


            app.js



            const myconfig = require('./configurations/myconfig');
            //IT ll fetch PORT ffrom process.env.PORT else not declare ll use default which is 8081 defined in myconfig.js

            const PORT=myconfig.get('PORT')//8081

            module.exports = function () {
            console.log("Process env is ::: ", process.env.NODE_ENV);
            if (process.env.NODE_ENV == 'production') {
            return {
            db : {
            host:process.env.HOST,
            database:process.env.DBNAME,
            username:process.env.username,
            password:process.env.password
            }
            }
            } else {
            return {
            db : {
            host:'localhost',
            batabase:'dbname',
            username:'',
            password:''
            }
            }
            }
            };


            You have to set your HOST/DBNAME/PASSWORD variables in production env[cloud heroku/aws/gcp]






            share|improve this answer














            You can use nconf npm



            let myconfig.js



            var nconf = module.exports = require('nconf');
            var path = require('path');

            nconf
            // 1. Command-line arguments
            .argv()
            // 2. Environment variables
            .env([
            'MYSQL_PASSWORD',
            'MYSQL_HOST',
            'PORT'
            ])
            // 3. Config file
            .file({file: path.join(__dirname, 'config.json')})
            // 4. Defaults
            .defaults({

            //Development DB config details
            MYSQL_USER: 'XXXX',
            MYSQL_PASSWORD: 'XXXX',
            MYSQL_HOST : 'localhost',
            PORT:8081

            });


            app.js



            const myconfig = require('./configurations/myconfig');
            //IT ll fetch PORT ffrom process.env.PORT else not declare ll use default which is 8081 defined in myconfig.js

            const PORT=myconfig.get('PORT')//8081

            module.exports = function () {
            console.log("Process env is ::: ", process.env.NODE_ENV);
            if (process.env.NODE_ENV == 'production') {
            return {
            db : {
            host:process.env.HOST,
            database:process.env.DBNAME,
            username:process.env.username,
            password:process.env.password
            }
            }
            } else {
            return {
            db : {
            host:'localhost',
            batabase:'dbname',
            username:'',
            password:''
            }
            }
            }
            };


            You have to set your HOST/DBNAME/PASSWORD variables in production env[cloud heroku/aws/gcp]







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 22 at 17:35

























            answered Nov 22 at 17:18









            BittuS

            417111




            417111












            • Thanks for reply. I want to do simple, and I want to just find issue in my code. I don't want to install any other modules. Can you please help to improve my code. :)
              – khushboo
              Nov 22 at 17:27










            • i have edited,if it is helpful@khushboo
              – BittuS
              Nov 22 at 17:36










            • I got TypeError: Cannot read property 'host' of undefined error
              – khushboo
              Nov 22 at 17:44










            • these variables you ll get in production enviornment after setting it,for local HOST=localhost PASSWORD=foobar node app.js while starting node application It ll set process.env.HOST=localhost
              – BittuS
              Nov 22 at 17:53




















            • Thanks for reply. I want to do simple, and I want to just find issue in my code. I don't want to install any other modules. Can you please help to improve my code. :)
              – khushboo
              Nov 22 at 17:27










            • i have edited,if it is helpful@khushboo
              – BittuS
              Nov 22 at 17:36










            • I got TypeError: Cannot read property 'host' of undefined error
              – khushboo
              Nov 22 at 17:44










            • these variables you ll get in production enviornment after setting it,for local HOST=localhost PASSWORD=foobar node app.js while starting node application It ll set process.env.HOST=localhost
              – BittuS
              Nov 22 at 17:53


















            Thanks for reply. I want to do simple, and I want to just find issue in my code. I don't want to install any other modules. Can you please help to improve my code. :)
            – khushboo
            Nov 22 at 17:27




            Thanks for reply. I want to do simple, and I want to just find issue in my code. I don't want to install any other modules. Can you please help to improve my code. :)
            – khushboo
            Nov 22 at 17:27












            i have edited,if it is helpful@khushboo
            – BittuS
            Nov 22 at 17:36




            i have edited,if it is helpful@khushboo
            – BittuS
            Nov 22 at 17:36












            I got TypeError: Cannot read property 'host' of undefined error
            – khushboo
            Nov 22 at 17:44




            I got TypeError: Cannot read property 'host' of undefined error
            – khushboo
            Nov 22 at 17:44












            these variables you ll get in production enviornment after setting it,for local HOST=localhost PASSWORD=foobar node app.js while starting node application It ll set process.env.HOST=localhost
            – BittuS
            Nov 22 at 17:53






            these variables you ll get in production enviornment after setting it,for local HOST=localhost PASSWORD=foobar node app.js while starting node application It ll set process.env.HOST=localhost
            – BittuS
            Nov 22 at 17:53




















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435103%2fsetup-app-production-and-developent-mode-in-node-js%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Trompette piccolo

            Slow SSRS Report in dynamic grouping and multiple parameters

            Simon Yates (cyclisme)