如何在不同的端口运行节点应用程序 - 暂时?

use*_*080 5 node.js express

在我的应用程序中,我有这样的配置:

 module.exports = {
     'port': process.env.PORT || 8080,
     'database': 'mongodb://xxx:xxxx@ds013456.mlab.com:13456/practical',
     'secret': 'ilovescotchscotchyscotchscotch'
 };
Run Code Online (Sandbox Code Playgroud)

但目前,我想用不同的PORT号码8081或其他方式运行我的应用程序.因为我需要运行2个不同的应用程序,配置方式相同.

什么是正确的方法? - 任何人帮助我?

提前致谢.

我已经尝试了这个答案:如何在node.js中更改process.env.PORT的值?

但我收到此错误:(我使用的是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
Run Code Online (Sandbox Code Playgroud)

Him*_*rma 10

这样做如果你想从process.env访问PORT varible,你必须使用这个命令来访问.

PORT = 8081节点server.js

.你使用了错误的语法