NodeJS和MAMP在本地机器上运行。 可能吗?

是否有可能在同一台机器上运行NodeJS和MAMP? 如果是的话,我将如何实现呢?

注意:我可以单独运行它们,但不能一起运行。 我假设使用“localhost”以及MAMP来使用NodeJS。

这取决于你想要NodeJs做什么?

你使用NodeJS作为networking服务器吗?

您可以将其设置为在另一个端口号上运行 – 这可以让您通过以下方式访问它:

var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); 

然后访问http:// localhost:1337

您可以设置代理和主机。

例如在Hosts中创buildnode01.example.com。 然后转到高级并在“自定义虚拟主机常规设置”中input以下内容

 ServerAlias node01.example.com

  <位置/>

   ProxyPass http://127.0.0.1:3000/

 ProxyPassReverse http://127.0.0.1:3000/

 </位置>

当您访问node01.example.com时,您将通过MAMP进入您的节点;)