如何在不同的端口运行节点应用程序 – 暂时?
在我的应用程序中,我有这样的configuration:
module.exports = { 'port': process.env.PORT || 8080, 'database': 'mongodb://xxx:xxxx@ds013456.mlab.com:13456/practical', 'secret': 'ilovescotchscotchyscotchscotch' };
但目前,我想运行我的应用程序在不同的端口号说, 8081
或别的东西。 因为我需要运行2个不同的应用程序configuration为相同的方式。
什么是正确的方法? – 任何一个帮助我?
提前致谢。
我已经试过这个答案: 如何更改node.js中process.env.PORT的值?
但是我得到这个错误:(我正在使用Windowsshell)
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 varible,你必须使用这个命令来访问。
PORT = 8081节点server.js
。 你正在使用错误的语法