【发布时间】:2017-01-21 04:25:04
【问题描述】:
在我的应用中,我有这样的配置:
module.exports = {
'port': process.env.PORT || 8080,
'database': 'mongodb://xxx:xxxx@ds013456.mlab.com:13456/practical',
'secret': 'ilovescotchscotchyscotchscotch'
};
但目前,我想以不同的端口号运行我的应用程序,例如 8081 或其他。因为我需要运行 2 个以相同方式配置的不同应用程序。
什么是正确的方法? - 有人帮帮我吗?
提前致谢。
我已经尝试过这个答案:How to change value of process.env.PORT in node.js?
但我收到此错误:(我使用的是 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
【问题讨论】:
-
我已经尝试了所有这些,但对我来说没有任何效果。让我发布错误,我得到了什么