[英]How to run the node app in different port - as temporarily?
在我的應用程序中,我有這樣的配置:
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
這樣做如果你想從 process.env 訪問 PORT 變量,你必須使用這個命令來訪問。
PORT=8081 節點 server.js
. 您使用了錯誤的語法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.