9

In my app, I have the configuration like this:

 module.exports = {
     'port': process.env.PORT || 8080,
     'database': 'mongodb://xxx:xxxx@ds013456.mlab.com: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
Community
  • 1
  • 1
user2024080
  • 1
  • 14
  • 56
  • 96

1 Answers1

22

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

Himanshu sharma
  • 7,487
  • 4
  • 42
  • 75