i'm running node server in development environment in server file shows unexpected behaviour
my script fallows:
var env = process.env.node_env; console.log("------------------------------"); console.log("envenv",typeof env,env); console.log("0",typeof env); console.log("00",env); console.log("2",env.tostring()=='development'); console.log("3",""+env.tostring()=='production'); console.log("2",env==='development'); console.log("3",env=="production"); console.log("------------------------------");
but gives following output
------------------------------ envenv string 'development' 0 string 00 'development' 2 false 3 false 2 false 3 false ------------------------------
when tried of following worked fine
var env = process.env.node_env.trim(); var env = process.env.node_env.tolowercase(); var env = process.env.node_env.replace("",""); .............
or method other tostring() in prototype of string class worked fine
the environment variable node_env contains superfluous '
. went wrong when setting environment variable. windows system use
> set node_env=development
instead of
> set node_env='development'
that should fix issue.
to current value of node_env printed on command line use
> echo %node_env%
that should print
> development
without " or '
Comments
Post a Comment