Wednesday 17 October 2018

[Help] Why doesn't this work?

to make things short, this is my code on a small project:const environment= process.env.NODE_ENV console.log(environment) //development console.log([environment]) // [ 'development' ] console.log(process.env.NODE_ENV) //development const stage = require('./config')[environment] console.log(stage) //undefined my config file is just an object: module.exports = { development: { port: process.env.PORT || 3000 } } NODE_ENV is set to development when i start the server.why is stage still undefined? environment is correctly set as development, and if i just useconst stage = require('./config').development everything works as it should.so why my stage const keep showing as undefined when i use NODE_ENV?thanks!

Submitted October 17, 2018 at 08:07PM by ImtheDr

No comments:

Post a Comment