Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run the node app in different port - as temporarily?

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
like image 278
user2024080 Avatar asked Sep 13 '16 14:09

user2024080


1 Answers

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

like image 88
Himanshu sharma Avatar answered Sep 29 '22 13:09

Himanshu sharma