In my app, I have the configuration like this:
module.exports = {
'port': process.env.PORT || 8080,
'database': 'mongodb://xxx:[email protected]:13456/practical',
'secret': 'ilovescotchscotchyscotchscotch'
};
but at present, I would like to run my app in different PORT number say, 8081
or something else. because I need to run 2 different apps which is configured as same way.
what is the correct way? - any one help me?
Thanks in advance.
I tried this answer already : How to change value of process.env.PORT in node.js?
But I am getting this error: ( I am using windows shell )
C:\Tutorials\try\NodePractical\MEAN-Family> env:PORT = 1234 server.js
env:PORT : The term 'env:PORT' 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
+ env:PORT = 1234 server.js
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (env:PORT:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Do like this If you want to access PORT variable from process.env you have to use this command to access.
PORT=8081 node server.js
. You are using wrong syntax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With