在我的应用程序中,我有这样的配置:
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)
| 归档时间: |
|
| 查看次数: |
12247 次 |
| 最近记录: |